cancel
Showing results for 
Search instead for 
Did you mean: 

Debugging an STM32L152RE with Sleep causes exception in Code, but , running code after removing the emulator and power cycling functions correctly

DFill.1
Associate II

I have a strange problem, I have ported the MBED-OS blinkly program to the IDE (this was a relatively painless process) , which sends the device to sleep between flashes. When I download and run the program with the emulator (I have tried blink, stink V2 and V3) it gets a hard memory fault. If I however power cycle the board removing the emulator. It works correctly.

I have enabled the debug core of the ST device

  HAL_EnableDBGStandbyMode() ;     // Enable Debugger in Standby Mode

  HAL_EnableDBGSleepMode() ;       // Enable Debugger in Sleep Mode

  HAL_EnableDBGStopMode();       // Enable Debugger in Stop Mode

If I build exactly the same code on GNU Arm Eclipse it functions with the debugger.

However I need to be able to debug Mbed projects in STM32cubeide as it is a requirement of my customer that I develop using this platform (it is a great platform )

Note that if I disable the sleep function in the code, it all works perfectly with the debugger.

Has anybody seen a problem like this or has a suggestion what I can do get the emulator to function I would be extremely grateful.

Thanks in advance for any help provided

David

3 REPLIES 3
DFill.1
Associate II

please read JLINK and STLINK for blink, stink, I missed the spelling checkers change :(

Uwe Bonnes
Principal III

You must activate DBGMCU_CR debugging in sleep/stop and standby.

DFill.1
Associate II

I believe a have already done this the macros, which are executed from Main before putting the device to sleep

HAL_EnableDBGStandbyMode() ;     // Enable Debugger in Standby Mode 

HAL_EnableDBGSleepMode() ;     // Enable Debugger in Sleep Mode

HAL_EnableDBGStopMode();      // Enable Debugger in Stop Mode

sets the relevant bits in the DBGMCU_CR (bits 0 to 2)