2024-05-21 09:04 AM
Hello,
I am trying to read multiple ADC channels using DMA. However, I cannot find scan mode configuration and rank selection in settings when I am setting up ADC on this particular board. Is there a way to set thrm up or any other way to read multiple channels at once?
Solved! Go to Solution.
2024-05-21 09:41 AM
Hello,
The scan mode is there but there is no ranking configuration on this device like other STM32 like STM32F4.
The scan mode can be Forward or Backward.
AdcHandle.Init.ScanConvMode = ADC_SCAN_DIRECTION_FORWARD;
#define ADC_SCAN_DIRECTION_FORWARD (0x00000001U) /*!< Scan direction forward: from channel 0 to channel 18 */
#define ADC_SCAN_DIRECTION_BACKWARD (0x00000002U) /*!< Scan direction backward: from channel 18 to channel 0 */
In ADC_CHSELR register if the corresponding channel bit is set, the channel will be part of the scan.
So if for example select CH0 and CH1 to be converted with Forward set the sequence will be CH0, CH1
If Backward is selected the sequence will be CH1 then CH0.
refer to the RM0377 rev 10/ section 13.3.8 Channel selection (CHSEL, SCANDIR)
2024-05-21 09:41 AM
Hello,
The scan mode is there but there is no ranking configuration on this device like other STM32 like STM32F4.
The scan mode can be Forward or Backward.
AdcHandle.Init.ScanConvMode = ADC_SCAN_DIRECTION_FORWARD;
#define ADC_SCAN_DIRECTION_FORWARD (0x00000001U) /*!< Scan direction forward: from channel 0 to channel 18 */
#define ADC_SCAN_DIRECTION_BACKWARD (0x00000002U) /*!< Scan direction backward: from channel 18 to channel 0 */
In ADC_CHSELR register if the corresponding channel bit is set, the channel will be part of the scan.
So if for example select CH0 and CH1 to be converted with Forward set the sequence will be CH0, CH1
If Backward is selected the sequence will be CH1 then CH0.
refer to the RM0377 rev 10/ section 13.3.8 Channel selection (CHSEL, SCANDIR)
2024-05-21 09:41 AM
It just lacks the hardware to change the channel order. There is nothing stopping you from implementing multi channel ADC. Data read from DMA is sorted according to ADC channel number.