STM32F103RB: Connecting to CPU via connect under reset failed after flashing a stop mode manager software
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