2019-10-18 08:08 PM
I'm using an STM32F446RE nucleo-64 board with STM32CubeIDE.
I was testing a potentiometer and noticed that the default code generated by cubeMX leads to an overrun error in the ADC peripheral. The issue can be manually solved by calling MX_DMA_Init() before MX_ADC1_Init() in main.c.
To reproduce the issue, my configuration on the CubeMX interface is as follows:
In main(), the regular conversion is triggered by HAL_DMA_START() just before the while loop.
This works as expected :
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_USART2_UART_Init();
MX_DMA_Init(); // Has been moved manually before MX_ADC1_Init();
MX_ADC1_Init();
if (HAL_ADC_Start_DMA(&hadc1, g_raw_adc_reading, BUFLENGTH) != HAL_OK)
Error_Handler();
while (1)
{
}
}
But if line 9 & 10 are inverted, as generated by cubeMX, the overrun flag will be set in the ADC1 status register. Unless I am missing something on the HAL library.
2019-10-19 12:33 AM
Yes, it appears to be an error.
JW
2021-11-25 03:25 AM
Yes, there's a problem in CubeMX. It has been 2years and still the issue persists!