"HAL_ADC_Start_DMA()" - init MSP bug
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.
