In one of my project, I am using interrupt and my microcontroller is Arduino Pro mini (5V, 16MHz) ATMega328. I am using both interrupts. Under each interrupt I am calling a function like following:
detachInterrupt(0);
A_SIG=1;
B_SIG=digitalRead(PinB); // PinB is another interrupt pin
if(B_SIG==0){
pulses++;
}
if(B_SIG==1){
pulses–;
}
attachInterrupt(0,A_FALL, FALLING);
I am interested if I can find how much time microcontroller will take to execute this part of the program. Because I have a feeling while executing this part of the program another interrupt happens and micrcontroller can not detect it. So, basically missing interrupts.
To see how long a bit of code takes, set a pin high just before the code in question and set it low right after. Then you can use a scope to see the width of the pulse.