Skip to main content
Nidhal Ben Othmen
Associate
May 4, 2021
Solved

STM32F103RB: Connecting to CPU via connect under reset failed after flashing a stop mode manager software

  • May 4, 2021
  • 5 replies
  • 5500 views

Hello,

I am using an STM32F103RB MCU in a specific Hardware design.

The Hardware was always working fine (it is a final product of medical customer) until I flashed a software which implements the stop mode (deep sleep mode) management (by setting the SLEEPDEEP bit in the System control register (SCB_SCR) and configuring the PWR_CR register).

Here is the code:

void PWR_EnterStopMode (uint8_t stopEntry)
{
 // Disable Systick Interrupt
 kSysTick->CTRL &= ~SYSTICK_CTRL_TICKINT_MSK;
 
 // clear Power down deepsleep
 kPWR->CR &= ~PWR_CR_PDDS_MSK;
 // Select stop mode
 kPWR->CR |= PWR_CR_LPDS_MSK;
 
 // Clear wake up flag
 kPWR->CR |= PWR_CR_CWUF_MSK;
 
 // Set sleep deep in ARM Cortex System control register
 kSCB->SCR |= SCB_SCR_SLEEPDEEP_MSK;
 
 if(stopEntry == PWR_LOWPOWER_ENTRY_WFI)
 {
 // Request wait for wakeup interrupt
 __WFI();
 }
 else
 {
 // Request wait for wakeup event
 __WFE();
 }
 /* Reset SLEEPDEEP bit of Cortex System Control Register */
 kSCB->SCR &= ~SCB_SCR_SLEEPDEEP_MSK;
 // Enable SysTick Timer & activate Systick IRQ, set SysTick Clock Source to Core Clock 
 kSysTick->CTRL |= SYSTICK_CTRL_TICKINT_MSK | SYSTICK_CTRL_ENABLE_MSK;
}

In the Software after calling WFI instruction (wait for interrupt) to wait for an interrupt to wake-up the micro-controller, it still sleeping for ever.

In debug session by pressing next step in IAR, I can go out from deep sleep mode.

When I go out from debug session, I can't connect anymore to the micro-controller and I can't flash it anymore.

I guess that because always when I power on the Hardware, the CPU goes directly in deep sleep mode.

I have the issue as described in the screenshot below:

0693W00000ANGfvQAH.png 

I am really stick with this and I look forward your help !

Best regards,

#STM32F1​ #Low-Power-Modes​

This topic has been closed for replies.
Best answer by Nidhal Ben Othmen

Thank you Mohamed and Tesla for your answers.

Actually, I resolved the issue! The problem is the NRST of the MCU is not connected to the RESET pin of the J-Link connector.

Connecting that, works well and I can flash the MCU with no problem.

5 replies

Mohamed Aymen HZAMI
ST Employee
May 6, 2021

Hello @Nidhal Ben Othmen​,

Try to change the system boot mode from Flash memory to SRAM in order to avoid entering the STOP2 directly when you power up the microcontroller.

You can find the configuration in the reference manual section 3.4 Boot configuration

Mohamed Aymen.

Nidhal Ben Othmen
Associate
May 6, 2021

Hello @Mohamed Aymen HZAMI​ ,

Thanks for your answer. But, this can be doable if I can program my MCU. Now, I can do nothing since the programmer can't access to the MCU.

Mohamed Aymen HZAMI
ST Employee
May 6, 2021

Try to put the BOOT0 pin in vdd !

Mohamed Aymen.

Tesla DeLorean
Guru
May 6, 2021

Connect Under Reset requires the NRST actually being wired on the JTAG/SWD interface

The BOOT0 HIGH trick can be more helpful as it stops your code from running at the next power up or reset.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Nidhal Ben Othmen
Nidhal Ben OthmenAuthorBest answer
Associate
May 6, 2021

Thank you Mohamed and Tesla for your answers.

Actually, I resolved the issue! The problem is the NRST of the MCU is not connected to the RESET pin of the J-Link connector.

Connecting that, works well and I can flash the MCU with no problem.