Let's Make Robots!

Checking bit in ISR


curiousity question what is more efficient. i have a hardware interrupt and inside the ISR i want to check another bit state(declare win).

is it better to test the if with a volatile uint8_t variable or do a checkbit macro directly?

in terms of efficiency and speed which is best.


thank you



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


i did not know this. thank you.

i shall try it and compare the outputs.




Without knowing exactly what the compiler is doing with those commands, the most effective way to check the efficiency is to compile both versions of the program and then disassemble the resulting hex file.

From the disassembly listing you can review which commands are actually being used by the micro to perform each command, and because the commands are down at the assembly/machine code level, they always take a fixed amount of time.
If you sum up all the command times for both versions of the ISR you'll be able to determine the exact execution times.

Take a look at this link for some info on using disassembly.