B4R Question Continuous ADC

canalrun

Well-Known Member
Licensed User
Longtime User
Hello,
I am working on an application that requires data to be collected continuously from an ADC channel on an ESP32 board.

Data will be collected from the ADC into a buffer while the previously collected buffer is being processed (FFTs, etc ...). I will create "Ping Pong" buffers. The processing should be completed well before a new buffer of data is collected, but will take much longer than the individual sample time.

Samples will be lost during processing unless I do something special.

I looked at "Looper", but this will not seem to interrupt a long-ish running process. Using a Timer would have the same problem.

I think what I need is interrupts - the foreground process is interrupted by a hardware timer so that I can read a sample from the ADC channel.

I've seen warnings from Erel about the possible problems that can occur using interrupts. I've also seen him mention that they can be achieved using in-line C.

If I go the in-line C route, I will need to read a boolean variable and an integer, then write to an unsigned integer array.

The "Pong" array is being processed while I write new ADC data to the "Ping" array. I should not be writing to the same data locations during interrupt and foreground processing - hopefully I can avoid any problems.

Is there an example or can someone point out how I may achieve interrupt processing using the ADC, in-line C, and B4R?

Barry.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…