Skip to main content
Graduate II
December 27, 2023
Solved

F411 Nucleo Board ADC Issues

  • December 27, 2023
  • 2 replies
  • 1671 views

I tried to use ADC in F411 to read two ADC inputs.

My hardware is a F411-Nucleo board; my IDE is CubeIDE.

The followings are my ADC settings in IDE:

Setting_1.PNGSetting_2.PNGSetting_3.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • I use 2 channels in ADC1 (IN1, IN4)
  • I also use DMA to obtain ADC results.

I use 

volatile uint16_t adc_reading[2]

to store the 2 readings.

Here is the code in the while loop of main.c

 while (1)
 {
	adc_read_complete = 0;
	HAL_ADC_Start_DMA(&hadc1, (uint32_t *)adc_reading, adc_ch_cnt);
	while(adc_read_complete == 0);
 /* USER CODE END WHILE */

 /* USER CODE BEGIN 3 */
 sprintf(uart2_str, "\t%d %d\n", adc_reading[0], adc_reading[1]);
	HAL_UART_Transmit(&huart2, (uint8_t *)uart2_str, strlen(uart2_str), 999);
	HAL_Delay(2500);
 }

adc_ch_cnt is 2.

I have two problems:

  1. Only adc_reading[0] has a valid reading; adc_reading[1] is always 0; even I define it as uint32_t variable and change data length as WORD. That valid reading corresponds to the voltage applied to IN4/PA4.
  2. The valid reading is only 8 bits long, instead of 12 bits; meaning value is 254~255  when I applied 3.3v to PA4 pin.

 

 

    This topic has been closed for replies.
    Best answer by HDaji.1

    Hi @GwenoleB

     

    Still does not work.

    However, I notice that there is something I did not do quite right.

    I am testing on an F411RE-Nucleo board, while I select F411RETx in the board selection. Is it the cause?

    I will retry from the board selection.

    2 replies

    ST Employee
    January 2, 2024

    Hello @HDaji.1,

    Could you please try again by using EOC flag defined as 'EOC flag at the end of all conversion' instead of 'single channel conversion'?

    Best Regards,

    Gwénolé

    HDaji.1AuthorAnswer
    Graduate II
    January 3, 2024

    Hi @GwenoleB

     

    Still does not work.

    However, I notice that there is something I did not do quite right.

    I am testing on an F411RE-Nucleo board, while I select F411RETx in the board selection. Is it the cause?

    I will retry from the board selection.

    HDaji.1Author
    Graduate II
    January 4, 2024

    I did again with Nucleo-F411RE in board selection step.

    Now it's working.

    However, the root cause is not clear to me.