cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 HAL ADC with DMA Init ends in Error_Handler (CubeMX)

Markus_H
Associate

Hello,

I am using an STM32H743VIH6 in a custom board. The MCU is running with 3,3V.

I generated code for the MCU with CubeMX and configured the clock, ADC1 and the DMA.

Attached the generated main.c file. Inside the fuction " MX_ADC1_Init" the Error_handler is called. Debugging shows me that "LL_ADC_REG_IsConversionOngoing(hadc->Instance)" is true, so the HAL goes to

/* Update ADC state machine to error */
 
   SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_INTERNAL);
 
 
   tmp_hal_status = HAL_ERROR;

and to the "Error_handler". I do not understand why there should be a conversion ongoing, it is still the initialization. I tested all my code on an Nucleo STM32H743ZI and all works fine. I also compared line for line of the generated CubeMX Code for the Nucleo and the custom board and except of the GPIO names/pins the initialization is the same.

I also tested a second PCB of the custom board to verify that it is not an broken MCU due to ESD or handling.

Any ideas why the initialization of the ADC fails?

CubeMX Version is 5.4.0 STM32H7 MCU package is 1.5.0

Thanks.

Kind Regards,

Markus

3 REPLIES 3
Markus_H
Associate

Changing the order of

MX_ADC1_Init();
MX_DMA_Init();

is already tested and does NOT change the behaviour.

Step through the code and observe how the registers are changing. Compare to expectation based on reading the ADC chapter in RM, and/or compare to the working example.

JW

PS. Please change your username to a normal nick.

MKowa.1
Associate

Hi,

I had the same issue. Every periferial works fine. When I try to use HAL_ADC_Start(&hadc1) or somethimes ADC_Init() program goes to Error_Handler.  And the reason was broken ADC in my STM32F103. I change uC in my PCB and problem gone.