Docsity

Microprocessor & Computer Architecture Lab: Polling vs. Interrupt Driven I/O, Slides of Microprocessor and Assembly Language Programming

Partial preview of the text

Download Microprocessor & Computer Architecture Lab: Polling vs. Interrupt Driven I/O and more Slides Microprocessor and Assembly Language Programming in PDF only on Docsity!

Microprocessor & Computer Architecture lab (EE3321) Lab 03

Polling vs. Interrupt Driven I/O

  • (^) Polling is constantly checking status of a port to see if data is available. Processor continually polls the port and when data is available, reads it.
  • (^) Polled I/O is inherently inefficient
  • (^) In interrupt driven I/O , I/O device interrupts the processor whenever it is ready. Processor responds to hardware interrupt by executing an interrupt service routine (ISR)
  • (^) Interrupt driven I/O is more efficient than polled I/O

Interrupt Service Routine(ISR)

  • (^) An interrupt service routine (ISR) is a software routine (Function) that hardware invokes in response to an interrupt
  • (^) Interrupt service routine should be a compact function that performs a specific task
  • (^) Interrupt Service Routine is also called Interrupt Handler

Program Flow with Interrupt

Enabling and disabling an interrupt

Following steps should be taken in order to enable any interrupt

  • (^) Bit D7 ( I ) of SREG (Status Register) must be set in order to enable the global interrupt without enabling global interrupt, no interrupt can happen. This can be done by using SEI (assembly instruction) or sei(); (C instruction).
  • (^) ]

External Interrupts Pins

  • (^) Three external hardware interrupts are I NT0 , INT1 and INT2 located on pins PD2 , PD3 and PB2 respectively.

General Interrupt Control Register(GICR)

MCUCSR

  • (^) INT2 can only be programmed to trigger on falling or rising edge through MCUCSR (MCU Control and Status Register).

General Interrupt Flag Register( GIFR)

  • (^) GIFR has external interrupt flags. When an external interrupt is occurs, corresponding flag of that external interrupt is raised. When microcontroller jumps of the interrupt vector table, flag is automatically cleared or we can clear the flag by writing high on it.

Programing

  • (^) DDRB=(1<<DDRB5)|(1<<DDRB3)|(1<<DDRB2)|(1<<DDRB1)| (1<<DDRB0);
  • (^) PORTB|=(1<<PORTB5);
  • (^) PORTB&=(1<<PORTB3);
  • (^) PORTD^=(1<<PORTD1);
  • (^) GICR=(1<<INT1);
  • (^) GICR=(1<<INT1)|(1<<INT0);
  • (^) sei();
  • (^) cli();
  • (^) MCUCR=(1<<ISC11);
  • (^) MCUCR=(1<<ISC11)|(1<<ISC10);

ISR Names for Timer Interrupt

  • (^) ISR(INT0_vect)
  • (^) ISR(INT1_vect)
  • (^) ISR(INT2_vect)