cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L151 Stop mode problem

rbaranov86
Associate II
Posted on October 14, 2014 at 11:13

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)
{
RTC_ClearITPendingBit(RTC_IT_WUT);
EXTI_ClearITPendingBit(EXTI_Line20);
if(PWR_GetFlagStatus(PWR_FLAG_WU) != RESET)
{
PWR_ClearFlag(PWR_FLAG_WU);
}
Program_Stat = RTC_WK_UP;
}
}
void EXTI3_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line3) != RESET)
{ 
EXTI_ClearITPendingBit(EXTI_Line3);
Program_Stat = ACTIVE; 
}
}

5 REPLIES 5
chen
Associate II
Posted on October 14, 2014 at 12:50

Hi

''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. ''

You cannot debug in any of the low power modes (Sleep, Stop, and Standby)

The debugger relies on communicating with the CPU core, when the CPU is in a low power mode, the CPU is stopped and therefore cannot communicate with the debugger.

You can set the CPU to debug in low power mode (it is a configuration of the debugger) but then the CPU is not really in a low power mode - it is faking it.

You cannot directly see with the debugger when the core is in low power mode - you have to infer it by measuring the current drop of the processor.

If you fake low power mode, then you will not measure a current drop.

rbaranov86
Associate II
Posted on October 14, 2014 at 13:26

Well, it's not true Stop Mode, but I don't see any problem after I call PWR_EnterSTOPMode first time, and debug still works. After second call it fails and I can not see program reaction on timer or external line.

And I also try to disable debug and disconnect adapter - the result is the same. I can see one pin toggle when exiting stop mode and that's all.

chen
Associate II
Posted on October 14, 2014 at 15:20

'' I don't see any problem after I call PWR_EnterSTOPMode first time, and debug still works. After second call it fails and I can not see program reaction on timer or external line.''

That might be because your program ends.

Your main() is NOT a loop but ends after the 2nd Stop mode entry.

I do not know what will happen in an embedded system if the main program exits/ends.

It may throw an exception.

It is unlikely to run any IRQs that you have programmed.

rbaranov86
Associate II
Posted on October 14, 2014 at 15:56

Loop gives same result. 

chen
Associate II
Posted on October 14, 2014 at 16:28

''Loop gives same result. ''

''the result is the same. I can see one pin toggle when exiting stop mode and that's all.''

What are you expecting? The IO pin to toggle all the time or the IO pin to toggle on Stop mode exit?

It is not a good idea to try to detect stop mode via IO pins, they can cause extra current to flow if they are driving something (eg LEDs)

It is best to test low power modes by measuring the current use of the processor.