This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

MKL03Z32 - debug not possible after adding code to go to low power states

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.

Parents
  • Before it gets to main() it likely executes SystemInit(), you'd want to check there what clocks are enabled, and what loops it may get stuck in.

    Understand why it Hard Faults, there is a pretty finite set of reasons that can occur and the processor flags a whole load of state information. Watch for clock relationships to be changed or screwed up after an exit from low power mode. Write some code to decompose register states with respect to the clocks, sources, and speeds.

    Check stack sizes
    Check flash wait states
    Check interrupt sources

Reply
  • Before it gets to main() it likely executes SystemInit(), you'd want to check there what clocks are enabled, and what loops it may get stuck in.

    Understand why it Hard Faults, there is a pretty finite set of reasons that can occur and the processor flags a whole load of state information. Watch for clock relationships to be changed or screwed up after an exit from low power mode. Write some code to decompose register states with respect to the clocks, sources, and speeds.

    Check stack sizes
    Check flash wait states
    Check interrupt sources

Children