IntervalTimer vs. TimerOne interrupts

Status
Not open for further replies.

jonatmudd

Member
For my application, I need to sample data from a device (biomed amplifier) at precisely timed intervals with microsecond resolution. Teensy 3.2 communicates with the amp via SPI. Looking at the IntervalTimer and TimeOne libs, is there any immediate practical difference? It seems either one of them would be suitable. Coding wise, there also seems to be little difference. Looking at the Interval Timer example and TimerOne example
its one vs. two lines, i.e,
Code:
myTimer.begin(blinkLED, 150000);
vs
Code:
Timer1.initialize(150000);
Timer1.attachInterrupt(blinkLED);

Also, I plan to use SPI within the interrupt, instead of just toggling the state of the LED (per the examples). When configuring SPI, is it necessary/advised to register the interrupt with SPI library? I.e.,
Code:
SPI.usingInterrupt(interrupt);

Maybe not, since my Teensy only communicates with only 1 SPI device? That is, I don't need to use transactional SPI selecting between 2 SPI devices with different settings, masking one of the interrupt flags as in this post .

If I do need to register the interrupt with the SPI library, what is the "interrupt number or name" in this case? I guess the interrupt is being generated by one of the timer flags, maybe something like TIMER0_COMPA_vect from this table?

Thanks in advance for any help/advice!
 
Status
Not open for further replies.
Back
Top