2021-05-04 03:25 AM
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:
I am really stick with this and I look forward your help !
Best regards,
#STM32F1 #Low-Power-Modes
Solved! Go to Solution.
2021-05-06 11:03 AM
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.
2021-05-06 04:06 AM
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.
2021-05-06 04:56 AM
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.
2021-05-06 05:34 AM
Try to put the BOOT0 pin in vdd !
Mohamed Aymen.
2021-05-06 06:32 AM
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.
2021-05-06 11:03 AM
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.