Pages: [1]   Go Down
Author Topic: Low interrupt  (Read 274 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
God Member
*****
Karma: 10
Posts: 649
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I know that if I put one of the two interrupts on my uno set to LOW it will fire over and over again as long as that pin stays LOW.  When it returns from the ISR, does it execute an instruction from the main code before it goes back into the ISR again?  Or will it freeze the main program and run the ISR like a loop?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16514
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I know that if I put one of the two interrupts on my uno set to LOW it will fire over and over again as long as that pin stays LOW.  When it returns from the ISR, does it execute an instruction from the main code before it goes back into the ISR again?  Or will it freeze the main program and run the ISR like a loop?

I believe it guarantees that one instruction in the main code will be allowed to execute before reissuing the interrupt. The datasheet for the specific AVR chip is of course the official reference for such information.

Lefty
Logged

Offline Offline
Full Member
***
Karma: 4
Posts: 187
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I know that if I put one of the two interrupts on my uno set to LOW it will fire over and over again as long as that pin stays LOW.  When it returns from the ISR, does it execute an instruction from the main code before it goes back into the ISR again?  Or will it freeze the main program and run the ISR like a loop?

Yes, in case of AVR processors, when an Interrupt Service Routine(ISR) finishes at least one opcode of the code execute before any other ISR is serviced.

RETI
ONE OPCODE AFTER RETI

Quote
LOW it will fire over and over again as long as that pin stays LOW
Yes, but most probably 1/3 of them will be lost.
Logged

From Idea To Invention

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's a bit more specific than that. If interrupts are enabled by an instruction, and they were previously not enabled, the processor will execute one more instruction before handling any interrupts.

So for example:

Code:
  cli ();
...
  sei ();
  sleep_cpu ();

The sleep_cpu() call is guaranteed to be executed, even if interrupts are pending.

Executing a RETI instruction usually is one of the cases of enabling interrupts.

Quote
Yes, but most probably 1/3 of them will be lost.

A LOW interrupt is not queued, and thus nothing is lost. Either the interrupt condition is present (ie. the pin is low) when the interrupt is being tested for, or not.

Logged

Offline Offline
Full Member
***
Karma: 4
Posts: 187
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
A LOW interrupt is not queued, and thus nothing is lost.

Correct, i got it.

Logged

From Idea To Invention

Pages: [1]   Go Up
Jump to: