2015-07-20 12:42 PM
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?2015-07-20 01:20 PM
RCC->APB1ENR |= (RCC_APB1ENR_PWREN); //??
2015-07-20 01:46 PM
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.