Interrupts Flashcards
What is an interrupt?
- an asynchronous signal to the processor indicating the need for attention (normally by hardware) or
- a synchronous event in software indicating the processor the need for a change in execution
ISR and IRQ?
ISR - interrupt service routine
IRQ - interrupt request (act of interrupting)
RETI used when?
ISR execution completes -> Returning from interrupt
–> restores registers and sets I-Bit in SREG
What is an interrupt source?
- signal starting an interrupt
- external = rising/fall ing edge
- internal = timer fired , ADC completion, I2C, SPI
What is an interrupt flag?
- each hardware interrupt source has an associate Interrupt flag which is indicating that an intterupt occured
What is the interrupt mask?
- Identical bit set to interrupt flag
- setting a bit here will trigger ISR (unmasking) if flag is set (enabing certain interrupt)
- when bit is cleared (masked), ISR is not executed, even if flag register signals an interrupt
What is the interrupt vector table?
- location in memory with adresses of ISRs
ISR Steps?
- relevant registers are pushed on stack (saving processors context)
- acknowleding the interrupt
- restoring the processor context
Example of an ISR definition (signal/interrupt). Explain difference=
- void ISRname (void) _ attribute _((signal, used));
- ‘used’ so that the compiler does not say function not used
- “ISRname” is predefined by the Machine
- interrupt (re-) enables interrupts on entry
What is a race conditions?
- Problems arising when using ISRs
- Situation where outcome varies depending on precise order in which instructions of main code and ISR are executed
What is a critical section?
Code that must be executed without interruptions
Example of an atomic access block?
Non-nested:
cli();
do_stuff();
sei();
For nested interrupts: uint8_t sreg = SREG; cli(); do_stuff(); SREG = sreg;
Definition: Time triggered system
- all activities are carried out at a certain point in time
- no interrupts except by timer
- schedule computed off-line (algorithms)
- deterministic behavior at run time
- interaction with environment through polling (con, critical aspect)