Description
According to https://raspberrypi.github.io/pico-sdk-doxygen/group__hardware__adc.html the Pico has 1 ADC with a 5 channel mux in front and one could use adc_set_round_robin()
to alternatively read from each.
A comment in https://github.com/raspberrypi/pico-examples/blob/master/adc/dma_capture/dma_capture.c says
// This could be extended to use the ADC's round robin feature to sample two
// channels concurrently at 0.25 Msps each.
But does not provide any clue on how to do that correctly. For example, is it possible to have two separate DMA capture buffers, which would be ideal? If so how? The SDK documentation does not say and seems to imply it's indeed not possible. If it is not possible to have separate capture buffers, the data in there will be all mingled from the various channels, and separating it will require some time. This is a problem if one needs a continuous capture. In such a case, once the DMA finishes, it needs to be restarted as soon as possible, ideally immediately. Would be possible to use a double capture buffer, alternating between one and the other to avoid waiting for the draining and separation of the original one? If so, how? If not, are all of the SDK channel configuration calls extremely fast compared to the sampling rate to make it a moot point? If so, it'd need to be mention.
The examples do not show any of this. It's straightforward to do round robin in the hello_adc
case in an infinite loop, like in the microphone_adc
example. Why is the microphone_adc
doing single conversions in a loop with sleep? For such a use case, a DMA approach seems the best way to proceed, to get a constant and consistent sample rate.... Or am I missing something and single conversions is the way to go? Round robin in single conversion mode would be trivial to implement.