cancel
Showing results for 
Search instead for 
Did you mean: 

Setting of MDK-ARM while STOP mode

HEhat.1
Associate II

Hello, I'm using STML052T8.

I'd like to debug while STOP mode on MDK-ARM.

How can I set up the MDK-ARM for STOP mode?

I'd like to know if there is a caution as this the first time to use MDK-ARM.

Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions

DBGMCU->CR |= DBGMCU_CR_DBG_STOP; /* To be able to debug in stop mode */

https://www.st.com/resource/en/reference_manual/dm00108281-ultralowpower-stm32l0x2-advanced-armbased-32bit-mcus-stmicroelectronics.pdf

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

View solution in original post

4 REPLIES 4
HEhat.1
Associate II

adding screenshot.

Click "Edit" then "configuration"?

But I still don't know how to do.

There is no configuration for STOP mode in MDK-ARM or μVision?

There is a DBG_CR register at 0x40015804, you could configure in your own code, or in a debug initialization script

Bit 0 DBG_SLEEP: Debug Sleep mode

0: In Sleep mode, FCLK is clocked by the system clock previously configured by the software while HCLK is disabled. The clock controller configuration is not reset and remains in its previously programmed state. As a consequence, when exiting from Sleep mode, the software does not need to reconfigure the clock controller.

1: In this case, when entering in Sleep mode, HCLK is fed by the same clock that is provided to FCLK (system clock previously configured by the software). 

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

DBGMCU->CR |= DBGMCU_CR_DBG_STOP; /* To be able to debug in stop mode */

https://www.st.com/resource/en/reference_manual/dm00108281-ultralowpower-stm32l0x2-advanced-armbased-32bit-mcus-stmicroelectronics.pdf

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

Thank you for your reply.

I have already tried to add "DBGMCU->CR |= DBGMCU_CR_DBG_STOP;r" but still it does not connect.

I confirmed following points:

・ The setting of MDK-ARM and μVsion are okay to debug during STOP mode.

・​After writing program to flash, MCU can execute user code and enter STOP mode.

・After entering STOP mode with "DBGMCU->CR |= DBGMCU_CR_DBG_STOP;", it can never come back from STOP mode and cannot connect debugger to MCU.

I doubt that:

・There is no supplying clock to MCU when returning from STOP mode.

・RDP is set.

The order to enter STOP mode in program is below. (These code is in the same function.)

  1. Disable systick (to prevent EXTI)
  2. Set "DBGMCU->CR |= DBGMCU_CR_DBG_STOP;"
  3. Enter STOP mode
  4. Enable systick

If you have any review, please add comment.

I also try to figure it out, thank you.

  ​