cancel
Showing results for 
Search instead for 
Did you mean: 

How to make STM32L071 wakeup from standby mode

WPuch
Associate II

I try to use standby mode on STM32L071. I slightly modified my code that worked fine on STM32L452RE. I use RTC wakeup and RTC alarms to be sure it will wake up (if RTC wakeup fails, 5 second later is ALARM A then 5 second later ALARM B)

Code below. nailesekund equals 60, timerega is set up for 65 seconds from current time, timeregb is set up 70 seconds from current time. Checked - values are OK.

 RCC_APB1ENR|=0x10000400; FLUSH;

 while(konsola_active) asm("wfi"); //waits for all pending characters transmitted on serial port

 CORTEX_SCR=0x04; // deep sleep enable

 PWR_CR=0x11A03;

 RCC_AHB2ENR|=0x7; FLUSH;

 GPIOA[GPIO_MODER]=0xFFFFFFFF;

 GPIOB[GPIO_MODER]=0xFFFFFFFF;

 GPIOC[GPIO_MODER]=0xFFFFFFFF;

 GPIOD[GPIO_MODER]=0xFFFFFFFF;

 GPIOE[GPIO_MODER]=0xFFFFFFFF;

 GPIOH[GPIO_MODER]=0xF;

 GPIOA[GPIO_PUPDR]=0;

 GPIOB[GPIO_PUPDR]=0;

 GPIOC[GPIO_PUPDR]=0;

 GPIOD[GPIO_PUPDR]=0;

 GPIOE[GPIO_PUPDR]=0;

 GPIOH[GPIO_PUPDR]=0;

FLUSH; RCC_IOPENR&=~0x9F;

 RTC_WPR=0xCA; RTC_WPR=0x53; FLUSH;

 RTC_ISR&=7; //czyszczenie wszystkich flag przerwań

 while(7!=(RTC_ISR&7)); //pozwolenie na zmiane rejestru wakeup timera i alarmów

 RTC_WUTR=nailesekund; //po tym czasie ma wakeup timer zadziałać

 RTC_ALRMAR=timerega|0x80000000;

 RTC_ALRMBR=timeregb|0x80000000;

 RTC_CR=0x7724; //wakeup timer+wakeup timer interrupt enable, wakeup timer liczony sekundami, alarm a i b

 RTC_ISR&=7;

 FLUSH; RTC_WPR=0; FLUSH;

 PWR_CR&=~(1<<8); FLUSH; //zablokowanie ustawień RTC

 RCC_APB1ENR&=~0x10000400; //wyłączenie taktowania RTC, PWR

 NVIC_ICER=0xFFFFFFFF;

//EXTI 20 RTC_WAKEUP 17 RTC_ALARM

//dorobić jeszcze reakcje na kontaktron!

 EXTI_FTSR=EXTI_RTSR=EXTI_IMR=(1<<20)|(1<<17);

 FLUSH;

 while(1) asm("wfi");

the result is that processor enters standby mode forever.

Very similar code worked fine for STM32L452 - CPU woke up after 60 seconds

Thank you for any help.

0 REPLIES 0