23
Microprocessors And Microcontrollers By: Dr. Attiya Baqai Semester : 4 th , 5 th (TL, ES) Assistant Professor, Course Code : ES256 , ES313 Department of Electronics, MUET.

Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU

  • Upload
    others

  • View
    19

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU

Microprocessors And Microcontrollers

By: Dr. Attiya Baqai

Semester : 4th , 5th (TL, ES) Assistant Professor,

Course Code : ES256 , ES313 Department of

Electronics, MUET.

Page 2: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU

AVR Interrupts concepts

◉ Interrupts

◉ Polling

◉ ISR (Interrupt Service Routine) or Interrupt handler

◉ Interrupt Vector Table

Page 3: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU

Interrupt Vector Table for ATmega32 AVR

Page 4: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU

Interrupt Vector Table for ATmega32 AVR

Page 5: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU

Steps in excecuting an Interrupt

◉ Finishes the current instruction. Stack← PC+1

◉ Jumps to Interrupt Vector Table. ISR ← IVR

◉ Executes ISR till RETI.

◉ PC ← Stack, continue main program.

Page 6: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU

Redirecting AVR from Interrupt vector Table at power up

Page 7: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU

Registers

◉ SREG (Status Register)-Enabling Global Interrupts

◉ GICR (General Interrupt Control Register)-For masking External Interrupts

◉ MCUCR (MCU Control Register)-Used to set Activating Logic/Edge of INT01

◉ MCUCSR (MCU Control & Status Register)-Used to set Activating Logic/Edge of INT2

◉ GIFR (General Interrupt Flag Register)-Used to check the status of Interrupt

Page 8: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU

Enabling Interrupts

◉On RESET, all interrupts are DISABLED (masked).

◉To use them, they MUST be ENABLED.

◉Make D7 in SREG as HIGH to Enable Interrupts

Page 9: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU

External Hardware Interrupts

ATMega32 Pin Diagram (40 PIN DIP)

Page 10: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU

External Hardware Interrupts

◉ INT0, INT1, INT 2

Page 11: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU

Example-10-5

Page 12: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU

Eg 10-5

Page 13: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU

Edge triggered vs level triggered

SM1 SM0SM2MCUCR SE ISC00ISC01ISC10ISC11

LDI R20,0x02 ;falling

OUT MCUCR,R20

Interrupt Sense Control Bits

Page 14: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU
Page 15: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU

INT2

- JTRFMCUCSR JTD PORFEXTRFBORFWDRFISC2

Page 16: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU
Page 17: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU
Page 18: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU
Page 19: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU
Page 20: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU
Page 21: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU

External Interrupt Status

◉ When an Edge Triggered Interrupt is activated, corresponding INTFx flag will be set to ONE.

◉The program will jump to ISR associated with that Interrupt.

Page 22: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU

More Interrupt concepts

◉ Interrupt priority.

◉ Interrupt inside an interrupt

◉ Interrupt latency

Page 23: Microprocessors And MicrocontrollersRegisters SREG (Status Register)-Enabling Global Interrupts GICR (General Interrupt Control Register)-For masking External Interrupts MCUCR (MCU

Any questions ?

Thanks!