AnsweredAssumed Answered

STM32L151 Stop mode problem

Question asked by T800 on Oct 14, 2014
Latest reply on Oct 14, 2014 by sung.chen_chung
Hi all!
I faced problem with STM32L151 and i hope to find some useful considerations.
The problem is following.
I use stop mode with RTC. RTC is configured with periodic wake-up timer. I also use external line to wake up from Stop mode. The controller goes to Stop mode and wakes up coorectly by timer or by external line. After that I config sys clock and do some actions with periferals. After everything is done, I set it to Stop mode again and the debug session fails. It looks like the core doesn't have any supply at all. 
The controller fails after __WFI(); then i use PWR_EnterSTOPMode second time.
I tried to disable debug and to disconnect ST-Link, but the result is the same.

int main()
  DBGMCU_Config(DBGMCU_SLEEP | DBGMCU_STANDBY | DBGMCU_STOP, ENABLE); //Enable debug in powersafe modes
 Init_Active();                         //Init active mode clocks & perif
 General_GPIO_Init();                                                        //Init GPIOs
 PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);
 Init_Active();                     //Init active mode clocks & perif
 //do some actions
 PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI); // here program fails
void RTC_WKUP_IRQHandler(void)
  if(RTC_GetITStatus(RTC_IT_WUT) != RESET)
    if(PWR_GetFlagStatus(PWR_FLAG_WU) != RESET)
    Program_Stat = RTC_WK_UP;
void EXTI3_IRQHandler(void)
  if(EXTI_GetITStatus(EXTI_Line3) != RESET)
    Program_Stat = ACTIVE;