Line 3: Line 3:
  
 
Steps to configure the Interrupts:
 
Steps to configure the Interrupts:
 
+
# Set Global Interrupt(I-bit) Enable bit in the AVR Status Register(SREG)
 +
# Set INT1 and INT0 bits in the General Interrupt Control Register (GICR)
 +
# Configure  MCU Control Register (MCUCR) to select interrupt type.
 +
# Handle the interrupt in the Interrupt Service Routine code.
  
 
=The Registers=
 
=The Registers=

Revision as of 15:48, 19 March 2016

We have looked at the basics of AVR Interrupts, now let us go ahead and use the External Interrupts feature on the AVR MCUs.

Steps to configure the Interrupts:

  1. Set Global Interrupt(I-bit) Enable bit in the AVR Status Register(SREG)
  2. Set INT1 and INT0 bits in the General Interrupt Control Register (GICR)
  3. Configure MCU Control Register (MCUCR) to select interrupt type.
  4. Handle the interrupt in the Interrupt Service Routine code.

The Registers

General Interrupt Control Register (GICR)

7 6 5 4 3 2 1 0
INT1 INT0 INT2 - - - IVSEL IVCE

MCU Control Register (MCUCR)

7 6 5 4 3 2 1 0
SE SM2 SM1 SM0 ISC11 ISC10 ISC01 ISC00
ISC01 ISC00 Description
0 0 The low level of INT0 generates an interrupt request.
0 1 Any logical change on INT0 generates an interrupt request.
1 0 The falling edge of INT0 generates an interrupt request.
1 1 The rising edge of INT0 generates an interrupt request.

General Interrupt Flag Register(GIFR)

7 6 5 4 3 2 1 0
INTF1 INTF0 INTF2 - - - - -


We will connect two switches to the two interrupt pins and show the status on a LCD. The connections are shown in the image below.

Hook Up

The Code

Downloads