Hello,
I am using Keil to develop code for my Cortex M0+ based MCU. I have added code to set the core to sleep state based on a certain condition.
The problem is that when I run the code on the MCU, all works fine. When I try to debug the code, the execution doesn't even get to the main().
The only possibilities I have during that debug session are to either click the reset button or the stop button on the debug interface. When I click on the stop button, call stack shows me that the execution stopped in a HardFault_Handler.
I am aware that in the low power mode that I am using the debug is not possible, but after a reset the core should run normally and then enter sleep state. Until that happens I should be able to debug!
I even tried to hack that the code tries to put the core in the run state (current state) again. Still the debug is not possible. Runs well on the MCU.
The new code with the low power modes enabled links wells and runs on the MCU. So I can't doubt the memory insufficiency. If I go back to my old code, debug is possible as normal.
Please help.
__main isn't your main() function - it's a library initialization function that sets up the runtime library before main() is called.
A C compiler normally adds one (1) _ prefix character to symbol names, just to make sure that C code symbols will not clash with any unknown assembler symbols.
Internal functions in the C runtime library are normally named with a leading _ in the C source code. So their external name seen by the linker will then have two leading _.