2023-09-01 08:52 AM
New to this ADC...I intend to call HAL_ADC_GetValue() from HAL_ADC_ConvCpltCallback().
How do I know which channel the conversion is for? Must HAL_ADC_ConvCpltCallback() keep track of the channel, trusting the ADC HW to follow the same channel ordering?
Solved! Go to Solution.
2023-09-01 09:47 AM - edited 2023-09-01 09:48 AM
The typical usage is to use polling for a single channel and use DMA for multiple channels. Using DMA will avoid an overrun condition and avoid needing to service the interrupt within a small time period. With DMA and multiple channels, you know the channel based on their index within the array.
This MCU has a small FIFO for the ADC, so you have a little buffer room, but not much, before an overrun happens.
But yes, you will need to keep track of the channel in software. When the EOC flag happens, there is no accompanying data on the channel that triggered it.
2023-09-01 09:47 AM - edited 2023-09-01 09:48 AM
The typical usage is to use polling for a single channel and use DMA for multiple channels. Using DMA will avoid an overrun condition and avoid needing to service the interrupt within a small time period. With DMA and multiple channels, you know the channel based on their index within the array.
This MCU has a small FIFO for the ADC, so you have a little buffer room, but not much, before an overrun happens.
But yes, you will need to keep track of the channel in software. When the EOC flag happens, there is no accompanying data on the channel that triggered it.