Thursday 9 June 2016

INTERRUPT using AVR:

Interrupts:

  • An interrupt is an external or internal event that interrupts the microcontroller to inform it that a device needs its service.
  • Interrupts vs. Polling • A single microcontroller can serve several devices. •
  • There are two ways to do that: – interrupts – Polling. •
  • The program which is associated with the interrupt is called the interrupt service routine (ISR) or interrupt handler.

Steps in Executing an Interrupt:

  • Finish current instruction and saves the PC on stack.
  • Jumps to a fixed location in memory depend on type of interrupt
  • Starts to execute the interrupt service routine until RETI (return from interrupt)
  • Upon executing the RETI the microcontroller returns to the place where it was interrupted. Get pop PC from stack

Types of Interrupt


Block Diagram of Interrupt



Program for External interrupt0 (INT0):

#include<avr/io.h>
#include<util/delay.h>
#include<avr/interrupt.h>
 ISR(INT0_vect)
{
PORTC=0x55;
}
void main()
{
sei();
MCUCR=0x02;
GICR=0x40;
DDRB=0xFF;
DDRC=0xFF;
while(1);
}

0 comments:

Post a Comment

if you have any doubt please let me know