I'm trying to build battery device with periodic wakeup by internal RTC or By Button press. Most of all time device in StandBy mode. And I need to wake up every 2 seconds do to some thing and return to StandBy. But Device don't waking up every two seconds, only by Button (rissing edge on PA0-WKUP_PIN).
I'm trying to use code from hal test:
Code: Select all
palSetPadMode(GPIOA, GPIOA_WKUP, PAL_MODE_INPUT_PULLDOWN);
....
//For Debugging
palClearPad(GPIOA, GPIOA_PA12);
palSetPadMode(GPIOA, GPIOA_WKUP, PAL_MODE_UNCONNECTED);
uint32_t tv_sec;
rtcGetTime(&RTCD1, ×pec);
/* set alarm in near future */
rtcSTM32GetSecMsec(&RTCD1, &tv_sec, NULL);
alarmspec.tv_sec = tv_sec + 2;
//rtcSetCallback(&RTCD1, alarm_cb);
rtcSetAlarm(&RTCD1, 0, &alarmspec);
chSysLock();
//DBGMCU->CR |= DBGMCU_CR_DBG_STANDBY;
PWR->CR = PWR_CR_CWUF | PWR_CR_CSBF | PWR_CR_PDDS | PWR_CR_LPDS;
PWR->CSR |= PWR_CSR_EWUP;
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
__WFI();
while(1);
By pressing on Button connected to PA0 - device waking up. But don't waking up periodically.
What I do wrong?