How many interrupt pins can I use at once?

Status
Not open for further replies.

stutchbury

New member
Quick question... I'm writing a 'wrapper' class for Paul's Excellent Encoder™ and Bounce2 classes to provide event driven callbacks, ultimately for a LinuxCNC control panel with four encoders (3 cheapies with push buttons and one CNC style pulse encoder dial).

My question is: How many interrupt pins can I use at once?

I understand on Teensy 4 all digital pins can be used as interrupts but this: https://www.pjrc.com/teensy/interrupts.html in section "Interrupt Vector, Mask & Flag Names" shows only two 'Pin Change' flags.

Does this mean I am limited to just one full hardware interrupt encoder?
 
The linked page seems to apply to AVR not ARM Teensy 4: To use interrupts, you must include the AVR interrupt header.

On Teensy 4 that wouldn't apply.

AFAIK - ALL - pins could be actively used.

When pin ports are configured as they are by default for high speed the interrupt detection is per port.

On interrupt the code then parses the mapped pins on that port and responds to them in parsed order. So worst case with over active pins it may be that those parsed later may get stale before they are processed? But that should not be an issue given the speed as long as all isr() responses are timely/short.
 
Quite a few PJRC Pages are unfortunately still written with the original 8-bit AVR Teensy in mind. The 32bit ARM Teensy boards got really spiffy interrupt controllers capable of handling more interrupts than you can wave a stick at. So you can go nuts in regards of attaching interrupts to ISRs really!


If one is willing they can also go and get nitty gritty with using one of the many CM7 Interrupt vectors on the Teensy4 directly. They take a wee bit of effort to setup, but with practice lets you pull off some really neat stuff like having a single ISR getting triggered by any change on an entire GPIO bus.
 
Quite a few PJRC Pages are unfortunately still written with the original 8-bit AVR Teensy in mind. The 32bit ARM Teensy boards got really spiffy interrupt controllers capable of handling more interrupts than you can wave a stick at. So you can go nuts in regards of attaching interrupts to ISRs really!


If one is willing they can also go and get nitty gritty with using one of the many CM7 Interrupt vectors on the Teensy4 directly. They take a wee bit of effort to setup, but with practice lets you pull off some really neat stuff like having a single ISR getting triggered by any change on an entire GPIO bus.

Indeed - just posted the above on Web-site-could-use-a-few-updates-)
 
The linked page seems to apply to AVR not ARM Teensy 4: To use interrupts, you must include the AVR interrupt header.
Thank you - I didn't spot that - I'm currently using an Arduino UNO (while I wait for my second Teensy 4 to arrive) but haven't had to explicitly include that header.

On Teensy 4 that wouldn't apply.

AFAIK - ALL - pins could be actively used.
I'm planning to use a Teensy 4, so that's good to hear.


On interrupt the code then parses the mapped pins on that port and responds to them in parsed order. So worst case with over active pins it may be that those parsed later may get stale before they are processed? But that should not be an issue given the speed as long as all isr() responses are timely/short.
Only one encoder will likely be used at a time but it's crucial it doesn't lose any steps.

Thank you for your reply.
 
Quite a few PJRC Pages are unfortunately still written with the original 8-bit AVR Teensy in mind. The 32bit ARM Teensy boards got really spiffy interrupt controllers capable of handling more interrupts than you can wave a stick at. So you can go nuts in regards of attaching interrupts to ISRs really!
I think four will be enough! But they might be spun quite quickly...

If one is willing they can also go and get nitty gritty with using one of the many CM7 Interrupt vectors on the Teensy4 directly. They take a wee bit of effort to setup, but with practice lets you pull off some really neat stuff like having a single ISR getting triggered by any change on an entire GPIO bus.
That might be somewhat above my needs/ability/pay grade!

Thank you for your reply.
 
I doubt us humans can spin an encoder faster than a Teensy can process them. Unless you can somehow turn them around thousands of rotation per second!!


Yeah i figured the direct approach would be overkill, but it is worth knowing that they exist and are very powerful.
Talking like monitoring 16 pins and triggering a read within 60 nanoseconds of any of them changing powerful!! :cool:
 
I certainly can't turn them faster than the ISR but it's fairly easy to overtake the loop() - so really appreciate Paul's Encoder lib read() method.
Always worth knowing what is available even if you don't understand or need it (yet).
 
Status
Not open for further replies.
Back
Top