Programable Elements I Interrupts
Programable Elements I Interrupts
Interrupts
Interrupt Definition
• Interrupt request, signal sent to the processor that temporarily
stops a running program and allows a special program,
an interrupt handler, to run instead.
LOWEST
Interrupt Vectors
Vector
Interrupt definition Vector name Vector
Number Interrupt definition Vector name
2 External Interrupt Request 0 INT0_vect Number
3 External Interrupt Request 1 INT1_vect 1 External Interrupt Request 0 INT0_vect
4 Pin Change Interrupt Request 0 PCINT0_vect 2 Pin Change Interrupt Request 0 PCINT0_vect
5 Pin Change Interrupt Request 1 PCINT1_vect
6 Pin Change Interrupt Request 2 PCINT2_vect 3 Timer/Counter1 Compare Match A TIMER1_COMPA_vect
7 Watchdog Time-out Interrupt WDT_vect
8 Timer/Counter2 Compare Match A TIMER2_COMPA_vect
4 Timer/Counter1 Overflow TIMER1_OVF_vect
9 Timer/Counter2 Compare Match B TIMER2_COMPB_vect
10 Timer/Counter2 Overflow TIMER2_OVF_vect 5 Timer/Counter0 Overflow TIMER0_OVF_vect
11 Timer/Counter1 Capture Event TIMER1_CAPT_vect
12 Timer/Counter1 Compare Match A TIMER1_COMPA_vect 6 EEPROM Ready EE_RDY_vect
13 Timer/Counter1 Compare Match B TIMER1_COMPB_vect 7 Analog Comparator ANA_COMP_vect
14 Timer/Counter1 Overflow TIMER1_OVF_vect
8 ADC Conversion Complete ADC_vect
15 Timer/Counter0 Compare Match A TIMER0_COMPA_vect
16 Timer/Counter0 Compare Match B TIMER0_COMPB_vect 9 Timer/Counter1 Compare Match B TIMER1_COMPB_vect
17 Timer/Counter0 Overflow TIMER0_OVF_vect
18 SPI Serial Transfer Complete SPI_STC_vect 10 Timer/Counter0 Compare Match A TIMER0_COMPA_vect
19 USART Rx Complete USART_RX_vect
20 USART Data Register Empty USART_UDRE_vect
11 Timer/Counter0 Compare Match B TIMER0_COMPB_vect
21 USART Tx Complete USART_TX_vect
22 ADC Conversion Complete ADC_vect 12 Watchdog Time-out WDT_vect
23 EEPROM Ready EE_READY_vect
24 Analog Comparator ANALOG_COMP_vect 13 USI Start Condition USI_START_vect
25 Two-wire Serial Interface TWI_vect 14 USI Overflow USI_OVF_vect
26 Store Program Memory Read SPM_READY_vect
External Interrupts
True Int vs Pin Change Interrupts
PCINTx, Shares ISR
INTx, individual ISR
Steps to configure the Interrupts:
External Interrupts
1.Set INT1 and INT0 bits in the respective Control Register
Example for ATMEGA328p
On ATTINY
External Interrupts
2. Set the Enable bit in it’s correct register
• Create a code which has a led blink at 1 sec intervals, using 4 interrupts when
a LOW signal is received make it blink twice at the following intervals:
• 1. 100 ms
• 2. 500 ms 3.
• 1.5 secs
• 4. 2secs
• Create a code to measure time, when an interrupt is activated save the time
passed and light a led the same amount of time passed, with a maximum
time of 6 seconds.