Teensy 4.1 precise analogRead timing?

albnys

Member
Hi!

I'm running a program on my Teensy 4.1 where the loop() takes around 10ms to execute (sometimes up to 30ms, due to heavy display code).

I need to read analogRead(A17) at least every 5ms and execute some simple code (also within the 5ms window) based on the analog input.

I've tried using analogread within intervalTimer.h ISR (which I've read is a bad idea) and it did indeed cause the loop to freeze while the ISR continues to execute normally.

Any suggestions on how to do this?
Thanks
 
Hi!

I'm running a program on my Teensy 4.1 where the loop() takes around 10ms to execute (sometimes up to 30ms, due to heavy display code).

I need to read analogRead(A17) at least every 5ms and execute some simple code (also within the 5ms window) based on the analog input.

I've tried using analogread within intervalTimer.h ISR (which I've read is a bad idea) and it did indeed cause the loop to freeze while the ISR continues to execute normally.

Any suggestions on how to do this?
Thanks
The ADC library has examples for how to do timed analog reads. Don’t know what you do on each read or anything about your display code, so can’t say more. Show your code!
 
Back
Top