-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
People ask if CircuitPython supports interrupts. It does not support user-written interrupt handlers in the way that MicroPython or Arduino do. However, it of course does use interrupts internally for specific functionality, such as PulseIn, countio, rotaryio, etc., etc.
MicroPython supports Pin interrupt handlers and Timer-based interrupt handlers. The MicroPython documentation describes a number of restrictions, caveats and warnings about interrupt handler routines. These kinds of issues, and the issues of using concurrency and shared objects safely, are some reasons we have felt interrupt support as found in MicroPython and Arduino is not a great match for our target audience.
What are your own specific cases for interrupts (that is, asynchronous event support)?
- What do you need to trigger on? E.g.:
a. A pin level change or edge.
b. Some microcontroller internal event (which ones?).
c. A timer-based interval. - What kind of latency is OK? (E.g., "soft" vs "hard" interrupts)
- What do you need to do when the event happens? E.g. (not inclusive):
a. Set a flag, to be checked later
b. Do something immediately (e.g., change another pin's value).
c. Ask for something to be done in the near future (e.g. read a sensor, write out some data).
We would not expect to satisfy all the requirements people have, but studying the kinds of things people want to do will be helpful towards coming up with mechanisms. Thanks. (For instance, #4540 describes of a use case that I thought of while thinking about posting this issue.)