Skip to main content
Explorer II
May 21, 2024
Solved

NUCLEO-L053R8 unable to configure ADC to read multiple channels

  • May 21, 2024
  • 2 replies
  • 1201 views

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?

    This topic has been closed for replies.
    Best answer by mƎALLEm

    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)

    SofLit_1-1716309641300.png

     

     

    2 replies

    mƎALLEmAnswer
    Technical Moderator
    May 21, 2024

    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)

    SofLit_1-1716309641300.png

     

     

    Graduate II
    May 21, 2024

    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.