System timer alarms of RP2040, anyone? #10713
Replies: 3 comments 6 replies
-
How is the alarm different from a timer interrupt? A quick look at https://raspberrypi.github.io/pico-sdk-doxygen/group__hardware__timer.html makes me wonder if they are the same. Micropython supports hardware timer callbacks. |
Beta Was this translation helpful? Give feedback.
-
I meant that in the MicroPython for RP2040. They call it a software timer rather than hardware. It was in the quote of the earlier message which is from the micropython rp2040 docs |
Beta Was this translation helpful? Give feedback.
-
This comes with a health warning as I haven't tried it. The following PIO state machine example shows how to generate a 1Hz timer and link it to a ISR. It should be possible to adjust this to any reasonable frequency. https://github.com/raspberrypi/pico-micropython-examples/blob/master/pio/pio_1hz.py There are other examples for 2000Hz. The examples run the ISRs in a soft (interruptible) context, but you could change this to hard (uninterruptible) by adding hard = True if desired. E.g This would avoid any complications associated with using the timer peripheral or setting the interrupt up yourself with the NVIC |
Beta Was this translation helpful? Give feedback.
-
I am thinking of using the alarms of this timer to generate a periodic interrupt. My idea is using the alarm ISR (there are up to four alarms according to the data sheet) as a poor man's RTOS, to execute some short tasks as fast as possible (after the alarm event) and with as low a jitter as possible.
Soo, the first question is: has anybody done that already? I would hate to reinvent the wheel.
Beta Was this translation helpful? Give feedback.
All reactions