cancel
Showing results for 
Search instead for 
Did you mean: 

"HAL_ADC_Start_DMA()" - init MSP bug

David Martins
Senior

I am working on a STM32f030.

I need to convert 2 channels of ADC, and decided to use DMA.

After reading the "HAL ADC Generic Driver" - UM1785 section, I got the idea that I don't have to use the "HAL_ADC_MspInit ()" function.

However, nothing works until I call this function again.

The following code is only for debugging and demonstrating the idea. Don't mind the rawness of it.

Do not work:

volatile uint16_t ADC_DMA[2] =
    { 0 };
 
    uint32_t timeout_ms;
 
    while (1)
    {
        timeout_ms = HAL_GetTick() + 50;
 
        adc_conv_done_flag = 0;
 
        HAL_ADC_Start_DMA(&hadc, (uint32_t*) ADC_DMA, 2);
        while (adc_conv_done_flag == 0)
        {
            if (HAL_GetTick() > timeout_ms)
                break;
        }
        HAL_ADC_Stop(&hadc);
 
        HAL_Delay(500);
    }

It works:

volatile uint16_t ADC_DMA[2] =
    { 0 };
 
    uint32_t timeout_ms;
	
	HAL_ADC_MspInit(&hadc);
 
    while (1)
    {
        timeout_ms = HAL_GetTick() + 50;
 
        adc_conv_done_flag = 0;
 
        HAL_ADC_Start_DMA(&hadc, (uint32_t*) ADC_DMA, 2);
        while (adc_conv_done_flag == 0)
        {
            if (HAL_GetTick() > timeout_ms)
                break;
        }
        HAL_ADC_Stop(&hadc);
 
        HAL_Delay(500);
    }

PS: adc_conv_done_flag is set on "HAL_ADC_ConvCpltCallback()" function.

Something here is not working as it should ... I've already lost a few hours following the ST documentation.

11 REPLIES 11

I'm facing CubeIDE still not allowing the MCU to be changed on projects without hacking the cproject​ and .ioc files, and the dual ADC regular mode still generating Irqs for both ADCs, and no reply from your colleagues about this issue

Hi @Robmar​ ,

1- Please, let us keep only one topic per thread.

2- May you share links to discussions where our support is still required? Very long discussions without describing exactly the issue are generally misleading.

3- As already said privately, we cannot ensure one to one support via Community; this is not the target here. For dedicated support, you need to contact your FAE.

Thanks for your understanding.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.