ULP RISC-V Interrupts/Timers
Posted: Tue Oct 22, 2024 10:46 pm
I’m working on using the ESP32's ULP (Ultra-Low Power) mode for activity tracking with an accelerometer, and I’m trying to figure out the best way to implement this.
Here’s what I want to achieve:
Mark Activity as Active/Inactive: I need to monitor each minute. If a wake-up interrupt occurs from the accelerometer, I mark that minute as "active." If no interrupt occurs, it should be marked as "inactive."
Timer for Inactive Periods: I want a timer running in the ULP that resets every minute, marking the period as "inactive" if there’s no wake-up interrupt.
Main Application Sync: When the main app wakes up, I want to back-calculate activity based on the ULP's runtime and sync it with a Unix timestamp to create accurate time-stamped data.
Question:
How can I set up the ULP to trigger at regular intervals (like every minute) for marking inactivity, while still allowing GPIO interrupts for activity detection? What’s the best way to handle the timing and interrupts together in this scenario? I would rather not be constantly polling but just have it act like a RTC timer to wake up the ULP if possible. And if a wake up interrupt occurs reset the timer.
Here’s what I want to achieve:
Mark Activity as Active/Inactive: I need to monitor each minute. If a wake-up interrupt occurs from the accelerometer, I mark that minute as "active." If no interrupt occurs, it should be marked as "inactive."
Timer for Inactive Periods: I want a timer running in the ULP that resets every minute, marking the period as "inactive" if there’s no wake-up interrupt.
Main Application Sync: When the main app wakes up, I want to back-calculate activity based on the ULP's runtime and sync it with a Unix timestamp to create accurate time-stamped data.
Question:
How can I set up the ULP to trigger at regular intervals (like every minute) for marking inactivity, while still allowing GPIO interrupts for activity detection? What’s the best way to handle the timing and interrupts together in this scenario? I would rather not be constantly polling but just have it act like a RTC timer to wake up the ULP if possible. And if a wake up interrupt occurs reset the timer.