Shop Learn
PASM2 Interrupt Example — Parallax Forums

PASM2 Interrupt Example

Does anyone have an interrupt routine example? I want to call a routine when a pin is pulled low. What are the considerations that should happen when an interrupt is called? (How to reset the interrupt, prevent it from looping, if that is a thing, etc)

Comments

  • evanhevanh Posts: 12,919

    There is a quick example in the silicon docs under "Interrupts" section. It uses a timer as the event source but demos the setup of connecting an IRQ to an event source and, in this case, also rearming the timer. The IRQ itself rearms upon exit with the special case of RETIx instruction.

    A pin input isn't a direct event source alone. You first have to configure an event that can monitor the pins. Mostly that means using one of the four "Selectable Event"s. eg: SETSE1 #%001_000000 | PINNUMBER. So read up on those. No rearming needed for pin inputs.

    My example SETSE1 uses a rising edge detection, so only one event per press. However, key debounce would be very wise to have to stop erratic events from mechanical contacts. Conveniently there is special hardware for that too. It requires the use of HUBSET though so is a little convoluted. I'll leave that one for later.

  • pik33pik33 Posts: 1,527
    edited 2022-02-08 07:12

    I use interrupts in my Amiga Paula inspired audio driver. Not very sophisticated but they do their job feeding DACs at 3.5 MHz rate. The topic: https://forums.parallax.com/discussion/174214/paula-amiga-inspired-audio-driver. The driver: https://github.com/pik33/P2-retromachine/tree/main/Propeller/Audiodriver

Sign In or Register to comment.