2023-12-26 11:16 PM
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:
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:
Solved! Go to Solution.
2024-01-02 06:20 PM
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.
2024-01-02 02:01 AM
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é
2024-01-02 06:20 PM
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.
2024-01-03 08:10 PM
I did again with Nucleo-F411RE in board selection step.
Now it's working.
However, the root cause is not clear to me.