My question: Once an interrupt is setup using the IntervalTimer class in the teensy core, when does the actual interrupt get reenabled. In my application it looks like the interrupt routine isn't reenabled until after the previous ISR completes. But when I look at the IntervalTimer class code, it looks to me like it should be reenabled as soon as the ISR is called.
I put together a simple example to test this:
#include <Arduino.h>
#include <IntervalTimer.h>
IntervalTimer updateTimer;
void myisr()
{
digitalWriteFast(6, HIGH);
digitalWriteFast(6, LOW);
delayMicroseconds(2000);
}
void setup()
{
pinMode(6, OUTPUT);
updateTimer.begin(myisr, 1000);
}
void loop()
{
}
I expected this to crash because I thought the the 2000 usec delay would cause myisr to be recalled every 1000 usec. Instead myisr executed once every 2000 usec.
Here is the part of the IntervallTimer class code where the actual timer isr code resides:
static void pit_isr()
{
IMXRT_PIT_CHANNEL_t *channel= IMXRT_PIT_CHANNELS;
if (funct_table[0] != nullptr && channel->TFLG) {channel->TFLG = 1;funct_table[0]();}
channel++;
if (funct_table[1] != nullptr && channel->TFLG) {channel->TFLG = 1;funct_table[1]();}
channel++;
if (funct_table[2] != nullptr && channel->TFLG) {channel->TFLG = 1;funct_table[2]();}
channel++;
if (funct_table[3] != nullptr && channel->TFLG) {channel->TFLG = 1;funct_table[3]();}
}
Because the TFLG flag is set to 1 before the call to the funct_table[0]() (this is myisr()), I thought the isr should be recalled before the 2000 usec delay is complete. Instead the pin high/low displayed on my scope shows that myisr is held off until the 2000 usec is passed.
So back to my original question-When does the actual isr get reenabled?
I put together a simple example to test this:
#include <Arduino.h>
#include <IntervalTimer.h>
IntervalTimer updateTimer;
void myisr()
{
digitalWriteFast(6, HIGH);
digitalWriteFast(6, LOW);
delayMicroseconds(2000);
}
void setup()
{
pinMode(6, OUTPUT);
updateTimer.begin(myisr, 1000);
}
void loop()
{
}
I expected this to crash because I thought the the 2000 usec delay would cause myisr to be recalled every 1000 usec. Instead myisr executed once every 2000 usec.
Here is the part of the IntervallTimer class code where the actual timer isr code resides:
static void pit_isr()
{
IMXRT_PIT_CHANNEL_t *channel= IMXRT_PIT_CHANNELS;
if (funct_table[0] != nullptr && channel->TFLG) {channel->TFLG = 1;funct_table[0]();}
channel++;
if (funct_table[1] != nullptr && channel->TFLG) {channel->TFLG = 1;funct_table[1]();}
channel++;
if (funct_table[2] != nullptr && channel->TFLG) {channel->TFLG = 1;funct_table[2]();}
channel++;
if (funct_table[3] != nullptr && channel->TFLG) {channel->TFLG = 1;funct_table[3]();}
}
Because the TFLG flag is set to 1 before the call to the funct_table[0]() (this is myisr()), I thought the isr should be recalled before the 2000 usec delay is complete. Instead the pin high/low displayed on my scope shows that myisr is held off until the 2000 usec is passed.
So back to my original question-When does the actual isr get reenabled?