Multiple Pins Interrupt ?

I try to expand the sample at to use one interrupt for two pins.

How would these small comparsion routine look like to have multiple pins with one interrupt?

I tried reading PIN Resgisters but they never seem to change, will i have to use Indio.digitalRead() insteat?

Won't this be "slow" ?



I am using the 32u4 Topboard

If i read PINB - PINF with CH1-8 configured as input with no Voltage on any Chanel, it will look like this:

PINB: 10111111
PINC: 1000000
PIND: 11110111
PINE: 100000
PINF: 10010010

If i now put Vin on any chanel it looks like this:

PINB: 11111111
PINC: 1000000
PIND: 11110111
PINE: 100000
PINF: 10010010

The same bit on PINB will change no matter wich chanel i put Vin on !?

Indio.digitalRead() does not work within an interrupt, the programm will stop, if i set a flag within the intterupt routine and use Indio.digitalRead within the main loop that would be just as fast (slow) as polling in the main loop.


Edit2: OK i unterstand why PINB-PINF is useless (ind.i/o channels are set/polled via i2c) But since Indio.digitalRead does not work within an ISR How can i read the status of an Input?





| 3 1 1
Asked on 2/13/16, 4:45 AM


I have the same problem.

The interrupt works, if i only use 1 input. If use more than 1 input, it´s impossible to know which input changed state within the interrupt code. I can do that in the main program, but my program is big, with big cycle times, and I need to count fast digital pulses.

I want to have a counter for each digital input using interrupts, but I think it will be impossible to do. Any suggestion?



Rui barroco
Rui barroco
| 1 0 1
Answered on 10/25/16, 10:57 AM

Your answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

Ask a Question

Keep Informed

About This Forum

This community is for professionals and enthusiasts of our products and services.

Read Guidelines

Question tools

19 follower(s)


Asked: 2/13/16, 4:45 AM
Seen: 3167 times
Last updated: 10/25/16, 10:57 AM