I'm using hardware interrupts INT0 and INT1 (Nano v3/328p) to decode a quadrature decoder . I am able to process incoming pulses at about 50KHz without losing counts.
I would like to know if the Arduino hardware interrupts are affected by timer prescalers, or any other register settings.
Are there any registers I could modify to increase the number of counts/second I can read, or is the hardware interrupt frequency just a function of the 16MHz clock?
renniejohnson:
I would like to know if the Arduino hardware interrupts are affected by timer prescalers, or any other register settings.
It is more likely that too many interrupts will affect other activities.
The time required to deal with an interrupt is governed by the small overhead for call and return plus the code that you include in the ISR. I imagine a rate far in excess of 50KHz per interrupt would be possible provided you have very little code in your ISR.
Of course there will come a point, no matter how short your ISR code, that you have so many interrupts there is no time to do anything useful.
If you need to find out how long a piece of code takes write a short sketch that repeats it 1000 times and see how long that takes by recording micros() before and after the 1000 repeats.
Good ideas, Robin2. I'll play with it and post some code if I can't get any improvement. I assume from your response that the ISR frequency is not dependent on any register settings, but just code and strategy related.
renniejohnson:
I assume from your response that the ISR frequency is not dependent on any register settings, but just code and strategy related.
Yes, except: some interrupts have a higher priority, so your interrupt might be delayed or missed if a higher priority ISR is already running. The datasheet lists the priority on page 57. Fortunately for you, the INT0/INT1 interrupts are already the highest priority.