wakup from sleep on falling edge

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

Moderators: RoccoMarco, barthess

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

wakup from sleep on falling edge

Postby hybridA » Thu Jun 15, 2023 4:03 am

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: 14458
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: wakup from sleep on falling edge

Postby Giovanni » Thu Jun 15, 2023 7:28 am

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


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 13 guests