cancel
Showing results for 
Search instead for 
Did you mean: 

wakeup STM32L0

yona
Associate

Hi

My name is Jonah and I’m working on STM32L031K4U6  .

My device needs to go to standby, wake up via PA2(WKUP3) or RTC wakeup

I follow  Doc RM0377 page 869 (to update PRER) , page 870(to update CR)

If I write : RTC->CR          =0x00000404U;  ( WUTE=1 but WUTIE=0)

      then RTC doesn’t wakeup ,still  , WKUP3   does wakeup.

If I write : RTC->CR           =0x00004404U;  (WUTE=1 but WUTIE=1) then:

   If WKUP3 occurs before 1st RTC wakeup than wakeup happens, yet RTC wakeup doesn’t.

Moreover- if  WKUP3 occur after RTC wakeup should have (but doesn’t) then no wakeup is achieved (anymore/ever)

I want to assume that the wakeup from standby is an event (WFE) and not an interrupt- although : I did try to activate the NVIC –still didn’t work.

If I write : RTC->CR           =0x00604404U;  (Wakeup output enabled) then RTC wakeup works, yet

PA2(WKUP3) doesn’t.

PA2(external pullup) goes low in a strange way- I can’t make out (goes low AFTER the wakeup was produced)

//------------------------------------------------------------------

    PWR->CSR=0x400; // WKUP3

   RCC->CSR      =0x00020001U;                   //p209  LSI on , feeding RTC (on)

   RCC->CSR      =0x00060001U;                   //p209  LSI on , feeding RTC (on)              

   RTC->WPR     =0x000000CAU;      RTC->WPR           =0x00000053U;    //p573 unlock write RTC regs

//exp p869            

  for(RTC->ISR=0x80;!(RTC->ISR & 0x40););   //p566

  RTC->PRER    =0x001C0070U;   //p569 prescalar p548    100mSec     (28+1)*(112+1)/32768=0.1Sec

  RTC->ISR=0;

//exp p870

  for(RTC->CR&=~0x400;!(RTC->ISR & 4););   //p551

  RTC->WUTR=ep.small_WK;                                                             //p570

  RTC->CR                                                            =0x00604404U;   //?????? p563   RTC/PRER for wakeup  +p159  

  RTC->WPR  =0x000000FEU;       RTC->WPR    =0x00000064U;                   //p534 lock write RTC regs            

                NVIC->ICPR[0]=0xFFFFFFFF;   //pp89

                PWR->CR                 =0xF05|0xA;           //p161  reset SBF

                SCB->SCR=0x04;           //pp97

                __WFE();

//-------------------------------------------------------------------

Does anybody know – what am I doing wrong?

Thanks

Jonah

 

 

 

1 REPLY 1
STTwo-32
ST Employee

Hello @yona 

I suggest you to take a look on how this is implemented in the Standby mode examples here. It should help you to understand how it works.

Best Regards.

STTwo-32 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.