2024-07-08 03:15 AM
Hello,
I am working with my custom PCB with STM32L053R8T6. My code works just fine when I run it in debug without any stop mode (deep sleep). It enters to the RTC and button interrupts perfectly. However, when I want to make the MCU enter to sleep mode the debug in Keil says:
* JLink Info: CPU could not be halted
***JLink Error: Cannot read register 15 (R15) while CPU is running
***JLink Error: Cannot read register 16 (XPSR) while CPU is running
***JLink Error: Cannot read register 0 (R0) while CPU is running
***JLink Error: Cannot read register 1 (R1) while CPU is running
***JLink Error: Cannot read register 2 (R2) while CPU is running
***JLink Error: Cannot read register 3 (R3) while CPU is running
***JLink Error: Cannot read register 4 (R4) while CPU is running
***JLink Error: Cannot read register 5 (R5) while CPU is running
***JLink Error: Cannot read register 6 (R6) while CPU is running
***JLink Error: Cannot read register 7 (R7) while CPU is running
***JLink Error: Cannot read register 8 (R8) while CPU is running
***JLink Error: Cannot read register 9 (R9) while CPU is running
***JLink Error: Cannot read register 10 (R10) while CPU is running
***JLink Error: Cannot read register 11 (R11) while CPU is running
***JLink Error: Cannot read register 12 (R12) while CPU is running
***JLink Error: Cannot read register 13 (R13) while CPU is running
***JLink Error: Cannot read register 14 (R14) while CPU is running
***JLink Error: Cannot read register 15 (R15) while CPU is running
***JLink Error: Cannot read register 16 (XPSR) while CPU is running
***JLink Error: Cannot read register 17 (MSP) while CPU is running
***JLink Error: Cannot read register 18 (PSP) while CPU is running
***JLink Error: Cannot read register 20 (CFBP) while CPU is running
I have attached the codes below. What can be the problem here? Can you help me.
2024-07-08 09:27 AM
Hi @nicatali007 ,
Referring to RM0367, debug connections are lost when you are in stop mode:
So, before entering stop mode, you need to set the DBG_STOP bit to ensure the debugger remains connected.
// Enable debug in STOP mode
DBGMCU->CR |= DBGMCU_CR_DBG_STOP;
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-07-09 02:22 AM
Thank you for the reply @Amel NASRI . I checked the register and yes it was set to 0. However, it still doesn't change after I added DBGMCU->CR |= DBGMCU_CR_DBG_STOP; . Is there anything else I should do before changing this register