wakup from sleep on falling edge

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
hybridA
Posts: 40
Joined: Wed Jan 12, 2022 7:15 am
Has thanked: 10 times
Been thanked: 5 times

wakup from sleep on falling edge

Post by hybridA »

I want to wakeup from deep sleep after 30seconds and on a falling edge of an input.
Here's the code that puts the MCU to sleep, as found here:

Code: Select all

    wakeupspec.wutr = ((uint32_t)4) << 16;
    wakeupspec.wutr |= 29;
    rtcSTM32SetPeriodicWakeup(&RTCD1, &wakeupspec);
    chSysLock();
    SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
    PWR->CR  |= (PWR_CR_PDDS | PWR_CR_LPDS | PWR_CR_CSBF | PWR_CR_CWUF);
    RTC->ISR &= ~(RTC_ISR_ALRBF | RTC_ISR_ALRAF | RTC_ISR_WUTF | RTC_ISR_TAMP1F |
                    RTC_ISR_TSOVF | RTC_ISR_TSF);
    __enable_irq();
    __WFI();


This works OK, as in waking up every 30 seconds.
Additionally I would want to wake up whenever PC13 is falling.

I tried using palEnablePadEvent(), but that didn't' work. Is there a hal wrapper, or does this have to be done on a register level?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: wakup from sleep on falling edge

Post by Giovanni »

Hi,

That PAL function enables "PAL events" (callbacks), not the EXTI events you need for wakeup. Try at register level, most of your code is done that way already.

Giovanni
Post Reply