This program should toggle the LED at pin 13. I've played with values for the timer period in 0.1 microsecond increments. Below a certain value, the LED stops toggling (evident on a scope), and the Teensy hangs up (button has to be pushed in order to get back into program mode, my informal indication that I've done something wrong).
About 0.7 microseconds on Teensy 3.6
About 1.6 microseconds on Teensy 4.0
I assume these details are due to how the microcontrollers handle interrupts. It creates a bit of a dilemma, since I want to run an ADC at 1 MHz, but also want the horsepower of the T4.0 board. Right now my ADC runs nicely at 250 kHz inside an IntervalTimer loop, and I'd like to replace it with a 1 MHz part, plus use the Teensy 4.0 for a screaming fast FFT.
About 0.7 microseconds on Teensy 3.6
About 1.6 microseconds on Teensy 4.0
I assume these details are due to how the microcontrollers handle interrupts. It creates a bit of a dilemma, since I want to run an ADC at 1 MHz, but also want the horsepower of the T4.0 board. Right now my ADC runs nicely at 250 kHz inside an IntervalTimer loop, and I'd like to replace it with a 1 MHz part, plus use the Teensy 4.0 for a screaming fast FFT.
Code:
IntervalTimer myTimer;
volatile int i;
void timerISR(){
i++;
}
void setup() {
pinMode(13, OUTPUT);
myTimer.priority(0);
myTimer.begin(timerISR, 1.5);
}
void loop() {
while(1) digitalWriteFast(13, i%2);