Which platforms currently support interrupts?


#1

Hello,

I was trawling through the Forum looking for more information on interrupts but it seems that it was kind of quasi abandoned a few years ago with AVR getting some support. Currently I’m working on a Raspberry Pi Pico W and wanted to have some of my sensors as interrupts.

Sincerely,
P_O


#2

That’s correct – I released an experimental version of uLisp for the AVR platforms that included support for interrupts, but that’s as far as it got, and there’s currently no support for interrupts in any of the main versions of uLisp.

The options would be:

  • Use the register command to set the appropriate bit in the pin change mask register, so a transition on a pin is latched in the pin change interrupt flag register. Then periodically poll the pin change interrupt flag register to detect when the pin change has occurred.

or:

  • Write a uLisp Extension file that implements interrupts, with an interrupt service that detects the interrupts and writes them to a location that can be queried from the Lisp program.

The terminology I’ve used is for AVR processors, but I assume something equivalent could be done on the RP2040.

For information about the register function see: Programming AVR registers or Programming ARM registers.

For information about writing an Extension File see: Adding your own functions.


#3

Setting a register seems like a good solution for the majority of use cases for interrupts. It would be nice to also include the ability to increment or decrement the register (for counting Semaphores), or include a stream (buffer or queue) where you could drop in a value, say a keystroke or DAC reading to be read later, the register could be updated to indicate how many values are currently held in the stream. Really I’d like to be allowed to supply a lambda function or closure to make it more dynamic but I could see how that could get out of hand quickly.

I guess the interrupt could be handled by storing a value in a register, and then there could be an interrupt mask table that contains pointers to the lambda functions that will deal with that value at a later scheduled event in the main loop.