cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L053 discovery standby

lee23
Associate II
Posted on July 20, 2015 at 21:42

I write some code that seems to successfully put the chip into standby mode:

    PWR->CR |= PWR_CR_PDDS;

    SCB->SCR |= SCB_SCR_SLEEPDEEP;

    while (1) { __asm(''WFI'')__; }

That seems to stop everything as expected. When I press the black reset button on the discovery, my code restarts as expected, but does not detect that it came out of Standby:

    if (0 != (PWR->CSR & PWR_CSR_SBF)) {

        from_standby = 1;

        PWR->CR |= PWR_CR_CSBF;

    }

    . . .

The flag ''from_standby'' is never set here. What I'm trying to do is keep the chip in Standby most of the time, but when I come out I want the RTC to be valid. It's running on the LSI, so it should be OK, but since my code always thinks this is the first power-on, it sets the RTC rather than just enabling it.

Is the black button on the discovery more than a reset, or is there something else I'm missing?

2 REPLIES 2
Posted on July 20, 2015 at 22:20

RCC->APB1ENR |= (RCC_APB1ENR_PWREN); //??

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
lee23
Associate II
Posted on July 20, 2015 at 22:46

Bingo, thanks. I forgot I turned that off in my RTC setup routine, so I had to add it back before setting PWR_CR_PDDS and before checking PWR_CSR_SBF.