2020-05-28 12:30 PM
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
2020-05-28 01:07 PM
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
2020-05-28 02:07 PM
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.
2020-05-28 02:17 PM
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.
2020-05-28 02:45 PM
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.