Regarding interrupt service routine

Status
Not open for further replies.

savvej

Member
one small doubt regarding avr atmega interrupts.When the program enters into the ISR,does it clear interrupt flag corresponding to that ISR only or does it disable all interrupts?
 
When an interrupt is triggered all interrupts are disabled. You can re-enable them in the ISR if you chose but you better know what other code could be executing, nested interrupts can be quiet complicated, and totally disastrous if you don't take into account the the status register itself is not independent of what else is going on in those ISRs. Generally speaking the FIRST thing an ISR should do is save the Sreg, and the last thing it should do before it reti's is restore the status register.



Might help you a bit.

While the ISR flag might be cleared keep in mind that even if global interrupts are disabled if an event occurs the specific events flag could be set to 1 again, basically causing as re-entrance into the ISR the moment it exits, perhaps not with intended consequences. This is most pronounced on high speed timers with triggers where a second event could occur before the first one is finished processing.
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…