Skip to main content
Visitor II
September 2, 2024
Question

STM32H743 Output of ADC on multiple channels with DMA is abnormal

  • September 2, 2024
  • 3 replies
  • 1652 views

I am trying to use ADC with DMA on STM32H743XI. I set up ADC1 IN7~IN9 and use three uint16_t to store their converted values. I use DMA2 Stream 0 to transfer data. CPU ICache and DCache as well as MPU are disabled. ADC Clock Mux is set to PLL2P 50MHz. SYSCLK is set to 480MHz. I also set up a USART1 to print results.

Below are some other settings on STM32CubeMX:

ADC settings:

LittleYe233_0-1725286242200.png

ADC DMA settings:

LittleYe233_1-1725286297830.png

This is how I define the result array:

 

uint16_t ADC_Values[ADC_N_CHANNELS] __attribute__((section(".ARM.__at_0x24000000")));

 

where `ADC_N_CHANNELS` is 3.

After initializing peripherals, I add the code below to the main function above the infinite while loop:

 

HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET, ADC_SINGLE_ENDED);
HAL_ADC_Start_DMA(&hadc1, (uint32_t *)ADC_Values, ADC_N_CHANNELS);

 

In the while loop I print the values of `ADC_Values` and delay for a sec. But it seems that the values of the array are always over 10,000, which are obviously abnormal. What's wrong with it? Any help will be highly appreciated.

    This topic has been closed for replies.

    3 replies

    Technical Moderator
    September 2, 2024

    Hello,

    I think you need to give more details and more code or if possible to attach your project.

    Visitor II
    September 3, 2024

    Hello, I have just added the compressed project to this post.

    Super User
    September 2, 2024

    > But it seems that the values of the array are always over 10,000, which are obviously abnormal.

    Why would that be obvious?

    What is connected to the respective pins?

    What hardware are you using, a "known good" board like Nucleo/Disco, or your own?

    How are those pins set (i.e. read out and check/post relevant GPIO registers content)?

    JW

    Visitor II
    September 3, 2024

    > Why would that be obvious?

    I have set the resolution of ADC to 12-bit. I think the converted value should be less than 4096.

    > What is connected to the respective pins?

    I connected the pin of ADC1 IN8 (I am sorry I forget which pin it is) to 3V3 on the board, others don't connect with any.

    > What hardware are you using, a "known good" board like Nucleo/Disco, or your own?

    A board from a local company, not from ST.

    > How are those pins set (i.e. read out and check/post relevant GPIO registers content)?

    I am sorry that I have no appropriate environment to check the registers. I will attach the content ASAP.

    Super User
    September 3, 2024

    > I have set the resolution of ADC to 12-bit. I think the converted value should be less than 4096.

    Without oversampling, yes.

    Read out the ADC registers content and check if it's set properly in that respect.

    JW

    Super User
    September 3, 2024

    > I have read the datasheet, and find that (if I haven't made mistakes) the base address of ADC1 is 0x40022000, the ADC_CFGR2 register has an offset of 0x10, and that the OVSS register is located at bits 8:5.

    This is simpler to do using a debugger.

    > Does it mean that the value of OVSS register is 0 (which means oversampling is disabled)?

    Yes. Similarly, you should check if the 12-bit mode is indeed set; and when at it, observe the data register too.

    I don't use the 'H7, maybe there's some other explanation for your observation.

    JW