cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 not entering main while(1) loop

Mdi c
Associate III

Hello,

I know, this problem might require a careful look into the code but I would like to ask for advice about where to start from.

Basically my problem is that the code does not enter in the while(1). I have the impression that this problem arised when I started adding DMA controlled peripherals such as ADCs and UART.

thank you

4 REPLIES 4

So stop in the debugger and determine where it has actually gone. Check code in startup.s, SystemInit(), etc.

Perhaps don't "run to main()" and walk it out of Reset_Handler on in.

Add diagnostic output to Error_Handler() and HardFault_Handler() so you can determine if it is in those while(1) loops

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Mdi c
Associate III

Hi @Community member​ , thank you, I will try to look there, but I can already say that if I stop the debugger I can see that the MCU is correctly executing the interrupt handlers in the code without getting any hard fault. The While loop seems to be executed only once or at least one part of it.

Ok, so an "Interrupt Storm", the chip will loop endlessly in a tail-chaining/reentry state if you fail to clear the pending interrupt. ie have UART TXE interrupt enabled, but never write data to the UART or disable.

Check what IRQ Handler is being called. Perhaps toggle a GPIO you can scope.

Check your service routines clear all pending sources.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
TDK
Guru

Ensure your interrupts are being called at a reasonable rate. If you try to call an interrupt at 1 MHz, your CPU will never have free time to execute the main code.

If you feel a post has answered your question, please click "Accept as Solution".