Quantcast
Channel: Raspberry Pi Forums
Viewing full articles (7807 articles)
Browse article index
↧

SDK • Advice on how to handle Race Conditions with the low Pstate functions

$
0
0
Hi!

I'm currently running a Pico 2 W with an ADXL343. I have the Pico go into low Pstate sleep to save energy, and wake up on an interrupt pin going HIGH from the AXDL343 when it detects sufficient acceleration in one axis. I'm having an issue in which I need to do the following actions at a very specific timeline:

1) Send an SPI command to the ADXL343 to reset the interrupt pin (thus go LOW, priming it for future interrupts), which takes some time to occur and have the pin go LOW

2) Go to low Pstate after it goes LOW, and ensure I go to low Pstate before the next interrupt occurs and sets the pin HIGH.

3) The next interrupt occurs, device wakes up as interrupt is now HIGH!

So, I can't go too fast nor too slow or I risk locking my device out since if the pin is HIGH when I go to low Pstate the device will go to sleep and never wake up again (even with the setting to have Pstate wake up on HIGH Level detection).

I can have a loop that resets the interrupt pin, waits a second, then checks it again and loops if it's back on HIGH. And while this probably would be all I really need out in the field, I would like to have a solution that 100% guarantees the device isn't just randomly bricked someday.

I could have it also wake up on a timer, but that has its own issues since doing so too frequently reduces the power saving benefits of low Pstate, and not frequently enough means that it might miss data that occurs in that period! Not a preferred solution of mine.

Any advice is welcome, thanks!

Statistics: Posted by lilithdotgov — Fri Aug 14, 2026 8:50 pm — Replies 0 — Views 23


↧

Viewing full articles (7807 articles)
Browse article index

Latest Images

Trending Articles



Latest Images