Potential race before entering low power state on STM32

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

Moderator: RoccoMarco

Post Reply
dflogeras
Posts: 232
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 8 times
Been thanked: 22 times

Potential race before entering low power state on STM32

Post by dflogeras »

Hi,

I often use the low power modes on STM32, and get woken up by a GPIO pin. It just occurred to me that there would be a race if the pin I am waiting for has already changed state before going into a low power state.

For instance,
if( palReadPad( ... )) {
PWR->CR |= ....;
...
__WFI();
}

In the unlikely event that pin changes state before __WFI() is called, I will miss the event. Is there a sane way to mitigate this?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Potential race before entering low power state on STM32

Post by Giovanni »

An external delay added to the line maybe.

Giovanni
alexblack
Posts: 277
Joined: Mon Sep 24, 2012 3:52 pm
Been thanked: 33 times

Re: Potential race before entering low power state on STM32

Post by alexblack »

Hi.
Use event instead of interrupt. Event will set pending bit, which may cleared only by WFE instruction.
Post Reply