Hi,
In my code I've got a minimal ISR that sets a volatile boolean. Later in the main loop I test the boolean. Very simple, works great.
But this ISR gets called at 2000hz, and I'm hunting for more cycles, so I am wondering about optimizations.
As I understand it, the mcu is configured so a rising edge on a pin sets an interrupt flag, and then the MCU serves the
interrupt ASAP by calling my ISR, and then clearing the flag.
Is it possible to set up the mcu to raise the interrupt flag on the rising edge but not try to call any ISR?
And then let me test and reset that flag from my main loop?
After all, a flag and a boolean are basically the same thing, so this would avoid the memory access
and whatever overhead is involved in getting into/out of the ISR. I have no idea how many cycles
this would save, but it just seems kind of wasteful to have an ISR that only sets a bool to true.
Or is there some other more normal paradigm for how to detect an interrupt from the main loop?
I assume I can't just use digitalRead(), since the interrupt arrives as a strobe pulse.
Thanks for any tips!
-mykle-
In my code I've got a minimal ISR that sets a volatile boolean. Later in the main loop I test the boolean. Very simple, works great.
But this ISR gets called at 2000hz, and I'm hunting for more cycles, so I am wondering about optimizations.
As I understand it, the mcu is configured so a rising edge on a pin sets an interrupt flag, and then the MCU serves the
interrupt ASAP by calling my ISR, and then clearing the flag.
Is it possible to set up the mcu to raise the interrupt flag on the rising edge but not try to call any ISR?
And then let me test and reset that flag from my main loop?
After all, a flag and a boolean are basically the same thing, so this would avoid the memory access
and whatever overhead is involved in getting into/out of the ISR. I have no idea how many cycles
this would save, but it just seems kind of wasteful to have an ISR that only sets a bool to true.
Or is there some other more normal paradigm for how to detect an interrupt from the main loop?
I assume I can't just use digitalRead(), since the interrupt arrives as a strobe pulse.
Thanks for any tips!
-mykle-