cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L152 - Stop Mode not working when using RTC Wakup

js23
Associate III
Posted on June 18, 2011 at 19:13

Hello,

just expierenced some strange problem. My app should go to Stop Mode and wake up when a signal on an EXTI line is detected or every 10s by RTC wakeup.

Without the RTC wakeup everything works fine, but when I activate the RTC wakeup, the PWR_EnterSTOPMode() seems to have no effect at all.

Code looks basically like this (LSE is used as RTC source, controller is running on MSI @2Mhz):

  

  ...

  GPIO_Config();

  RTC_Config();

  SysTick_Config (2000000 / 100); // approx 10ms interrupt

  RTC_WakeUpCmd(ENABLE);

  PWR_VoltageScalingConfig(PWR_VoltageScaling_Range3);

  PWR_UltraLowPowerCmd(ENABLE);

  PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);

  ...

When I remove RTC_WakeUpCmd(ENABLE); everything is OK, Stop Mode is working, power consumption is approx 1.4uA.

Any ideas... what am I doing wrong?? I already tried inserting PWR_ClearFlag(PWR_FLAG_WU); before entering stop mode, just to be sure. No success.

Thanks in advance,

Johannes

One additional note: Just took the code and loaded it (after some minor adaptions) on a STM32F205 - No problems there, everything works as it should.

#stop-mode #stm32l #stm32l-stop-mode
7 REPLIES 7
js23
Associate III
Posted on June 20, 2011 at 11:53

Seems that I found a solution: Obviously the SYSTICK is the problem - When the SYSTICK interrupt is disabled, everything is OK. The code that helped for me:

   ...

   SysTick->CTRL  &= ~SysTick_CTRL_TICKINT_Msk ;

   PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);

   ...

Weird. Something for the errata sheet? BTW: My chip revisions is 'X'.

But there is some other issue now: Power consumption is only 1.4uA until the RTC wakeup IRQ is called for the first time. After the IRQ is executed the first time it rises to 3.4uA and there seems to be nothing that I can do to lower it again.

Interestingly, 3.4uA is the value I get when I do not call PWR_UltraLowPowerCmd(). But calling it again did not help, too.

Regards,

Johannes
js23
Associate III
Posted on June 20, 2011 at 18:15

My power consumption problem is now fixed, too. This time PWR_ClearFlag(PWR_FLAG_WU); helped. My stop mode entry now looks like that:

    SysTick->CTRL  &= ~SysTick_CTRL_TICKINT_Msk;        // systick IRQ off

    PWR_ClearFlag(PWR_FLAG_WU);

    PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);

    SysTick->CTRL  |= SysTick_CTRL_TICKINT_Msk;            // systick IRQ on

Took me some time to find out... Maybe this is helpfull to semobody else...

BTW: Power consumption is now stable at 1.4uA (for complete board @2.7V). IMHO an impressive value for a 16K SRAM device...

Regards,

Johannes

tamaneko
Associate
Posted on November 14, 2012 at 21:08

Just a quick note of thanks for posting this.  I was seeing the same extra current draw in stop mode after an RTC wake-up, and clearing the wake up flag in the PWR_CSR did the trick to get the current draw back where it should be.

Brad                      B-)

Posted on November 15, 2012 at 09:34

Couldn't these issues be related to the way how you debug the application?

I am speculating here based on what is said in chapter 24.14 of the STM32L15x manual: The SysTick timer clock is not stopped during the Stop mode debug (DBG_STOP bit set).

The counter keeps on being decremented and can generate interrupts if they are enabled.

I could envisage that some of the debugging tools (or maybe the toolchain set to generate a ''debugging-mode'' binary) set this bit quietly without notifying the user... ?

JW
jonas2
Associate
Posted on October 14, 2016 at 11:08

Hi Johannes,

I know it's a long time ago you posted this but I have a question for you. I want to put my STM32L152RE in ''stop mode with rtc'' and wake him up by detecting a push on a button or with rtc wakeup every 10 seconds for example. Could you tell me the steps I have to take to configure the rtc wakeup interval and what I have to do before entering stop mode and what when leaving stop mode. Some example code would be very helpful. Thanks in advance! 

Regards Jonas

Walid FTITI_O
Senior II
Posted on October 14, 2016 at 18:06

Hi boussery.jonas, 

I suggest to follow the steps of oth examples in

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-embedded-software/stm32cubel1.html

''PWR_STOP_RTC'' at this path: STM32Cube_FW_L1_V1.6.0\Projects\STM32L152RE-Nucleo\Examples\PWR\PWR_STOP_RTC

This example shows how to enter Stop mode and wake up from this mode by using the RTC wakeup timer event connected to an interrupt.

For the wake-up pin configuration you should add the configuration of the pin as interupt enabled coonected to EXTI0. . You can use just the following BSP function :

    BSP_PB_Init(BUTTON_USER, BUTTON_MODE_EXTI);

-Hannibal-
jonas2
Associate
Posted on October 28, 2016 at 14:32

Thank you for the tips. I was able to solve my problem.