ESP32 Can't sample ADC inside Interrupt Macro
Posted: Fri Dec 08, 2023 2:25 pm
I am trying to port a program that I have working on an Arduino nano over to an ESP32.
One of the things I do in my program is sample 4 ADC channels in an interrupt running at 1kHz. Ideally, I would like to run my interrupt at 2kHz, but the nano can't do it, so I wanted to see if the ESP32 could do it faster.
I wrote a simple test program on the ESP32 and got the interrupt running at 500 microseconds. All I do in the ISR is toggle an output so that I can measure the timing on a scope.
I can read one ADC channel outside the interrupt and it takes 140 microseconds to read the ADC. As soon as I put the read ADC command inside the ISR macro, the interrupt stops running and my program keeps restarting.
I attached my program. Please let me know if you have any ideas.
One of the things I do in my program is sample 4 ADC channels in an interrupt running at 1kHz. Ideally, I would like to run my interrupt at 2kHz, but the nano can't do it, so I wanted to see if the ESP32 could do it faster.
I wrote a simple test program on the ESP32 and got the interrupt running at 500 microseconds. All I do in the ISR is toggle an output so that I can measure the timing on a scope.
I can read one ADC channel outside the interrupt and it takes 140 microseconds to read the ADC. As soon as I put the read ADC command inside the ISR macro, the interrupt stops running and my program keeps restarting.
I attached my program. Please let me know if you have any ideas.