SlideShare a Scribd company logo
1 of 15
Download to read offline
Interrupts in Atmega328P
(Lecture-13)
R S Ananda Murthy
Associate Professor and Head
Department of Electrical & Electronics Engineering,
Sri Jayachamarajendra College of Engineering,
Mysore 570 006
R S Ananda Murthy Interrupts in Atmega328P
Methods of I/O Operation
Synchronous I/O operation.
This is possible when the I/O device operates at the same
speed as that of MCU.
In this case the I/O operation with the device is performed
by the MCU assuming that the device is always ready.
Asynchronous I/O Operation.
In this case, generally the I/O device is very slow when
compared to the MCU. Then, it can perform I/O operation
by the following methods:
By polling.
By using interrupts.
R S Ananda Murthy Interrupts in Atmega328P
I/O Operation by Polling
Is
the device
ready
?
Request device to get ready
Service the device
No
Yes
Polling results in waste of MCU time and power and does
not permit masking of devices since all devices have to be
checked.
R S Ananda Murthy Interrupts in Atmega328P
Polling Example
R S Ananda Murthy Interrupts in Atmega328P
I/O Operation by Interrupts
The MCU keeps on doing some useful operation, or it
remains in a low-power state after enabling interrupts.
When I/O device is ready, it interrupts the MCU.
The MCU completes execution of the current instruction,
saves the return address on the stack, and then jumps to
the Interrupt Service Routine (ISR) to serve the device.
After this, the MCU returns back to the interrupted program
by loading the return address from the stack to the
Program Counter.
Interrupts can be enabled or disabled dynamically and
when multiple interrupts come simultaneously priorities
can be assigned.
R S Ananda Murthy Interrupts in Atmega328P
Interrupt Example
R S Ananda Murthy Interrupts in Atmega328P
Default Interrupt Vectors in Atmega328P
R S Ananda Murthy Interrupts in Atmega328P
Interrupt Vectors in Atmega328P
Interrupt vector is a definite address in the program
memory where a JMP instruction should be written to jump
to the ISR corresponding to the interrupt.
Each interrupt vector occupies two program memory words
in order to provide space for JMP instruction.
In Atmega328P, the RESET Vector is affected by
BOOTRST fuse and the Interrupt Vector start address is
affected by IVSEL bit in the MCUCR.
R S Ananda Murthy Interrupts in Atmega328P
Enabling and Disabling Interrupts in Atmega328P
In SREG if I = 1, then all interrupts are enabled.
We can make I = 1 by using SEI instruction in ALP and
sei() function in C program.
In SREG if I = 0, then all interrupts are disabled.
We can make I = 0 by using CLI instruction in ALP and
cli() function in C program.
Upon reset I = 0 so all interrupts are disabled.
R S Ananda Murthy Interrupts in Atmega328P
Bits of EICRA Control Nature of INT1 and INT0
Bits 7, 6, 5, and 4 are not used and are always read as 0.
R S Ananda Murthy Interrupts in Atmega328P
Bits of EIMSK Mask/Unmask INT1 and INT0
Masking/unmasking means disabling/enabling respectively.
When INT1 = 1 INT1 is unmasked if I = 1 in SREG.
When INT1 = 0 INT1 is masked even if I = 1 in SREG.
When INT0 = 1 INT0 is unmasked if I = 1 in SREG.
When INT0 = 0 INT0 is masked even if I = 1 in SREG.
Activity on the pins of INT1/INT0 will cause an interrupt
request even if the corresponding pins are configured as
output pins.
Bits 2 to 7 are unused and will always be read as 0.
R S Ananda Murthy Interrupts in Atmega328P
Bits of EIFR Show Status of INT1 and INT0
Bits 2 to 7 are unused and will always be read as 0.
When INT1 interrupt is triggered, INTF1 becomes 1. This
flag is cleared when ISR is executed.
When INT0 interrupt is triggered, INTF0 becomes 1. This
flag is cleared when ISR is executed.
INTF1/INTF0 flags can be cleared by writing a logical 1 to
the respective bit.
INTF1/INTF0 flags are always cleared when the respective
interrupts are configured as a level interrupt.
R S Ananda Murthy Interrupts in Atmega328P
C-Code to use INT0
R S Ananda Murthy Interrupts in Atmega328P
Problem Statement to use INT0/INT1
Assume that a push button is connected to the INT0/PD2 pin of
Atmega328P MCU with internal pull-up resistor enabled and
that a 7-segment common cathode display is connected to
PORTB lines of the MCU through 330Ω current limiting
resistors. Let a high-to-low logic change on this pin cause an
INT0 interrupt. Sketch a diagram showing the hardware
connections. Write a program in C which displays on the LED
display any integer in the range 1 to 6, both inclusive, when
ever the push button is pressed, thus simulating throwing of a
die. Sketch a flow chart to show the logic.
Also write ALP to achieve the task mentioned above.
Modify the programs written above to use INT1/PD3.
R S Ananda Murthy Interrupts in Atmega328P
License
This work is licensed under a
Creative Commons Attribution 4.0 International License.
R S Ananda Murthy Interrupts in Atmega328P

More Related Content

What's hot

Embedded system design using arduino
Embedded system design using arduinoEmbedded system design using arduino
Embedded system design using arduinoSantosh Verma
 
AVR Fundamentals
AVR FundamentalsAVR Fundamentals
AVR FundamentalsVinit Vyas
 
Automatic Room Lights Controller Using Arduino & PIR Sensor
Automatic Room Lights Controller Using Arduino & PIR SensorAutomatic Room Lights Controller Using Arduino & PIR Sensor
Automatic Room Lights Controller Using Arduino & PIR SensorAnkit Chaudhary
 
PIC 16F877A by PARTHIBAN. S.
PIC 16F877A   by PARTHIBAN. S.PIC 16F877A   by PARTHIBAN. S.
PIC 16F877A by PARTHIBAN. S.parthi_arjun
 
PIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESPIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESDr.YNM
 
Embedded system (Chapter 2) part A
Embedded system (Chapter 2) part AEmbedded system (Chapter 2) part A
Embedded system (Chapter 2) part AIkhwan_Fakrudin
 
INTRODUCTION TO MICROCONTROLLER
INTRODUCTION TO MICROCONTROLLERINTRODUCTION TO MICROCONTROLLER
INTRODUCTION TO MICROCONTROLLERAnkita Jaiswal
 
L11 assembly-language-programming-of-atmega328 p
L11 assembly-language-programming-of-atmega328 pL11 assembly-language-programming-of-atmega328 p
L11 assembly-language-programming-of-atmega328 prsamurti
 
PIC-18 Microcontroller
PIC-18 MicrocontrollerPIC-18 Microcontroller
PIC-18 MicrocontrollerASHISH RANJAN
 
L9 understanding-atmega328 p-2
L9 understanding-atmega328 p-2L9 understanding-atmega328 p-2
L9 understanding-atmega328 p-2rsamurti
 
register file structure of PIC controller
register file structure of PIC controllerregister file structure of PIC controller
register file structure of PIC controllerNirbhay Singh
 
Introduction to Microcontroller
Introduction to MicrocontrollerIntroduction to Microcontroller
Introduction to MicrocontrollerNikhil Sharma
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architectureJamia Hamdard
 
8-bit PIC Microcontrollers
8-bit PIC Microcontrollers8-bit PIC Microcontrollers
8-bit PIC MicrocontrollersPremier Farnell
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architectureDominicHendry
 

What's hot (20)

AVR ATmega32
AVR ATmega32AVR ATmega32
AVR ATmega32
 
Embedded system design using arduino
Embedded system design using arduinoEmbedded system design using arduino
Embedded system design using arduino
 
ATMEGA 328
ATMEGA 328ATMEGA 328
ATMEGA 328
 
AVR Fundamentals
AVR FundamentalsAVR Fundamentals
AVR Fundamentals
 
Automatic Room Lights Controller Using Arduino & PIR Sensor
Automatic Room Lights Controller Using Arduino & PIR SensorAutomatic Room Lights Controller Using Arduino & PIR Sensor
Automatic Room Lights Controller Using Arduino & PIR Sensor
 
PIC 16F877A by PARTHIBAN. S.
PIC 16F877A   by PARTHIBAN. S.PIC 16F877A   by PARTHIBAN. S.
PIC 16F877A by PARTHIBAN. S.
 
Atmega32
Atmega32Atmega32
Atmega32
 
PIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESPIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTES
 
8051 MICROCONTROLLER
8051 MICROCONTROLLER 8051 MICROCONTROLLER
8051 MICROCONTROLLER
 
Embedded system (Chapter 2) part A
Embedded system (Chapter 2) part AEmbedded system (Chapter 2) part A
Embedded system (Chapter 2) part A
 
INTRODUCTION TO MICROCONTROLLER
INTRODUCTION TO MICROCONTROLLERINTRODUCTION TO MICROCONTROLLER
INTRODUCTION TO MICROCONTROLLER
 
L11 assembly-language-programming-of-atmega328 p
L11 assembly-language-programming-of-atmega328 pL11 assembly-language-programming-of-atmega328 p
L11 assembly-language-programming-of-atmega328 p
 
PIC-18 Microcontroller
PIC-18 MicrocontrollerPIC-18 Microcontroller
PIC-18 Microcontroller
 
L9 understanding-atmega328 p-2
L9 understanding-atmega328 p-2L9 understanding-atmega328 p-2
L9 understanding-atmega328 p-2
 
register file structure of PIC controller
register file structure of PIC controllerregister file structure of PIC controller
register file structure of PIC controller
 
Introduction to Microcontroller
Introduction to MicrocontrollerIntroduction to Microcontroller
Introduction to Microcontroller
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architecture
 
8-bit PIC Microcontrollers
8-bit PIC Microcontrollers8-bit PIC Microcontrollers
8-bit PIC Microcontrollers
 
PIC Microcontrollers
PIC MicrocontrollersPIC Microcontrollers
PIC Microcontrollers
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architecture
 

Viewers also liked

Lecture-1 : Introduction to Power Electronics
Lecture-1 : Introduction to Power ElectronicsLecture-1 : Introduction to Power Electronics
Lecture-1 : Introduction to Power Electronicsrsamurti
 
Trends in-power-electronics
Trends in-power-electronicsTrends in-power-electronics
Trends in-power-electronicsrsamurti
 
L5 data-parallel-computers
L5 data-parallel-computersL5 data-parallel-computers
L5 data-parallel-computersrsamurti
 
L6 primary-memory
L6 primary-memoryL6 primary-memory
L6 primary-memoryrsamurti
 
L1 intro-to-mpu-mcu
L1 intro-to-mpu-mcuL1 intro-to-mpu-mcu
L1 intro-to-mpu-mcursamurti
 
Introduction to-Tex-and-LaTeX
Introduction to-Tex-and-LaTeXIntroduction to-Tex-and-LaTeX
Introduction to-Tex-and-LaTeXrsamurti
 
Transformers
TransformersTransformers
Transformersrsamurti
 
L4 speeding-up-execution
L4 speeding-up-executionL4 speeding-up-execution
L4 speeding-up-executionrsamurti
 
Lecture-5 : Semiconductor Power Switching Devices-2
Lecture-5 : Semiconductor Power Switching Devices-2Lecture-5 : Semiconductor Power Switching Devices-2
Lecture-5 : Semiconductor Power Switching Devices-2rsamurti
 
L3 instruction-execution-steps
L3 instruction-execution-stepsL3 instruction-execution-steps
L3 instruction-execution-stepsrsamurti
 
L7 starting-to-use-mcu
L7 starting-to-use-mcuL7 starting-to-use-mcu
L7 starting-to-use-mcursamurti
 
Lecture-3 : More Applications of Power Electronics
Lecture-3 : More Applications of Power ElectronicsLecture-3 : More Applications of Power Electronics
Lecture-3 : More Applications of Power Electronicsrsamurti
 
Lecture-7 : Semiconductor Power Switching Devices-4
Lecture-7 : Semiconductor Power Switching Devices-4Lecture-7 : Semiconductor Power Switching Devices-4
Lecture-7 : Semiconductor Power Switching Devices-4rsamurti
 
Lecture-2 : Applications of Power Electronics
Lecture-2 : Applications of Power ElectronicsLecture-2 : Applications of Power Electronics
Lecture-2 : Applications of Power Electronicsrsamurti
 
L14 kb-lcd-interfacing-with-atmega328 p
L14 kb-lcd-interfacing-with-atmega328 pL14 kb-lcd-interfacing-with-atmega328 p
L14 kb-lcd-interfacing-with-atmega328 prsamurti
 
Three phase-circuits
Three phase-circuitsThree phase-circuits
Three phase-circuitsrsamurti
 
L16 usart-atmega328 p
L16 usart-atmega328 pL16 usart-atmega328 p
L16 usart-atmega328 prsamurti
 
Synchronous generators
Synchronous generatorsSynchronous generators
Synchronous generatorsrsamurti
 
L10 assembly-language-programming-of-atmega328 p
L10 assembly-language-programming-of-atmega328 pL10 assembly-language-programming-of-atmega328 p
L10 assembly-language-programming-of-atmega328 prsamurti
 
Lecture-4 : Semiconductor Power Switching Devices-1
Lecture-4 : Semiconductor Power Switching Devices-1Lecture-4 : Semiconductor Power Switching Devices-1
Lecture-4 : Semiconductor Power Switching Devices-1rsamurti
 

Viewers also liked (20)

Lecture-1 : Introduction to Power Electronics
Lecture-1 : Introduction to Power ElectronicsLecture-1 : Introduction to Power Electronics
Lecture-1 : Introduction to Power Electronics
 
Trends in-power-electronics
Trends in-power-electronicsTrends in-power-electronics
Trends in-power-electronics
 
L5 data-parallel-computers
L5 data-parallel-computersL5 data-parallel-computers
L5 data-parallel-computers
 
L6 primary-memory
L6 primary-memoryL6 primary-memory
L6 primary-memory
 
L1 intro-to-mpu-mcu
L1 intro-to-mpu-mcuL1 intro-to-mpu-mcu
L1 intro-to-mpu-mcu
 
Introduction to-Tex-and-LaTeX
Introduction to-Tex-and-LaTeXIntroduction to-Tex-and-LaTeX
Introduction to-Tex-and-LaTeX
 
Transformers
TransformersTransformers
Transformers
 
L4 speeding-up-execution
L4 speeding-up-executionL4 speeding-up-execution
L4 speeding-up-execution
 
Lecture-5 : Semiconductor Power Switching Devices-2
Lecture-5 : Semiconductor Power Switching Devices-2Lecture-5 : Semiconductor Power Switching Devices-2
Lecture-5 : Semiconductor Power Switching Devices-2
 
L3 instruction-execution-steps
L3 instruction-execution-stepsL3 instruction-execution-steps
L3 instruction-execution-steps
 
L7 starting-to-use-mcu
L7 starting-to-use-mcuL7 starting-to-use-mcu
L7 starting-to-use-mcu
 
Lecture-3 : More Applications of Power Electronics
Lecture-3 : More Applications of Power ElectronicsLecture-3 : More Applications of Power Electronics
Lecture-3 : More Applications of Power Electronics
 
Lecture-7 : Semiconductor Power Switching Devices-4
Lecture-7 : Semiconductor Power Switching Devices-4Lecture-7 : Semiconductor Power Switching Devices-4
Lecture-7 : Semiconductor Power Switching Devices-4
 
Lecture-2 : Applications of Power Electronics
Lecture-2 : Applications of Power ElectronicsLecture-2 : Applications of Power Electronics
Lecture-2 : Applications of Power Electronics
 
L14 kb-lcd-interfacing-with-atmega328 p
L14 kb-lcd-interfacing-with-atmega328 pL14 kb-lcd-interfacing-with-atmega328 p
L14 kb-lcd-interfacing-with-atmega328 p
 
Three phase-circuits
Three phase-circuitsThree phase-circuits
Three phase-circuits
 
L16 usart-atmega328 p
L16 usart-atmega328 pL16 usart-atmega328 p
L16 usart-atmega328 p
 
Synchronous generators
Synchronous generatorsSynchronous generators
Synchronous generators
 
L10 assembly-language-programming-of-atmega328 p
L10 assembly-language-programming-of-atmega328 pL10 assembly-language-programming-of-atmega328 p
L10 assembly-language-programming-of-atmega328 p
 
Lecture-4 : Semiconductor Power Switching Devices-1
Lecture-4 : Semiconductor Power Switching Devices-1Lecture-4 : Semiconductor Power Switching Devices-1
Lecture-4 : Semiconductor Power Switching Devices-1
 

Similar to L13 interrupts-in-atmega328 p

Interrupt in ATMEGA328P.pptx
Interrupt in ATMEGA328P.pptxInterrupt in ATMEGA328P.pptx
Interrupt in ATMEGA328P.pptxSujalKumar73
 
Interrupt11
Interrupt11Interrupt11
Interrupt11Aisu
 
Chapter 4 - Interrupts of 8085
Chapter 4 - Interrupts of 8085Chapter 4 - Interrupts of 8085
Chapter 4 - Interrupts of 8085Bisrat Girma
 
Types of Interrupts with details Mi ppt
Types of Interrupts with details Mi pptTypes of Interrupts with details Mi ppt
Types of Interrupts with details Mi pptsanjaytron
 
8085 interrupts
8085 interrupts8085 interrupts
8085 interruptsIsha Negi
 
8085 interrupts
8085 interrupts8085 interrupts
8085 interruptsIsha Negi
 
Interrupts of 8085
Interrupts of 8085Interrupts of 8085
Interrupts of 8085ShivamSood22
 
pdf-obstacle-avoiding-robot.docx
pdf-obstacle-avoiding-robot.docxpdf-obstacle-avoiding-robot.docx
pdf-obstacle-avoiding-robot.docxmaheshwaran79
 

Similar to L13 interrupts-in-atmega328 p (20)

Interrupt in ATMEGA328P.pptx
Interrupt in ATMEGA328P.pptxInterrupt in ATMEGA328P.pptx
Interrupt in ATMEGA328P.pptx
 
Interrupt
InterruptInterrupt
Interrupt
 
Interrupt11
Interrupt11Interrupt11
Interrupt11
 
Chapter 4 - Interrupts of 8085
Chapter 4 - Interrupts of 8085Chapter 4 - Interrupts of 8085
Chapter 4 - Interrupts of 8085
 
Interrupt 8085
Interrupt 8085Interrupt 8085
Interrupt 8085
 
Types of Interrupts with details Mi ppt
Types of Interrupts with details Mi pptTypes of Interrupts with details Mi ppt
Types of Interrupts with details Mi ppt
 
8085 interrupts
8085 interrupts8085 interrupts
8085 interrupts
 
8085 interrupts
8085 interrupts8085 interrupts
8085 interrupts
 
8051 Inturrpt
8051 Inturrpt8051 Inturrpt
8051 Inturrpt
 
Interrupt in 8051
Interrupt in 8051Interrupt in 8051
Interrupt in 8051
 
8085 interrupts
8085 interrupts8085 interrupts
8085 interrupts
 
Interrupts
InterruptsInterrupts
Interrupts
 
Interruptsof8085
Interruptsof8085Interruptsof8085
Interruptsof8085
 
Interrupts
InterruptsInterrupts
Interrupts
 
Interrupts of 8085
Interrupts of 8085Interrupts of 8085
Interrupts of 8085
 
Interrupts of microprocessor 8085
Interrupts of microprocessor  8085Interrupts of microprocessor  8085
Interrupts of microprocessor 8085
 
pdf-obstacle-avoiding-robot.docx
pdf-obstacle-avoiding-robot.docxpdf-obstacle-avoiding-robot.docx
pdf-obstacle-avoiding-robot.docx
 
Drivers2
Drivers2Drivers2
Drivers2
 
Drivers2
Drivers2Drivers2
Drivers2
 
8085 interrupts
8085 interrupts8085 interrupts
8085 interrupts
 

Recently uploaded

Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 

Recently uploaded (20)

Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 

L13 interrupts-in-atmega328 p

  • 1. Interrupts in Atmega328P (Lecture-13) R S Ananda Murthy Associate Professor and Head Department of Electrical & Electronics Engineering, Sri Jayachamarajendra College of Engineering, Mysore 570 006 R S Ananda Murthy Interrupts in Atmega328P
  • 2. Methods of I/O Operation Synchronous I/O operation. This is possible when the I/O device operates at the same speed as that of MCU. In this case the I/O operation with the device is performed by the MCU assuming that the device is always ready. Asynchronous I/O Operation. In this case, generally the I/O device is very slow when compared to the MCU. Then, it can perform I/O operation by the following methods: By polling. By using interrupts. R S Ananda Murthy Interrupts in Atmega328P
  • 3. I/O Operation by Polling Is the device ready ? Request device to get ready Service the device No Yes Polling results in waste of MCU time and power and does not permit masking of devices since all devices have to be checked. R S Ananda Murthy Interrupts in Atmega328P
  • 4. Polling Example R S Ananda Murthy Interrupts in Atmega328P
  • 5. I/O Operation by Interrupts The MCU keeps on doing some useful operation, or it remains in a low-power state after enabling interrupts. When I/O device is ready, it interrupts the MCU. The MCU completes execution of the current instruction, saves the return address on the stack, and then jumps to the Interrupt Service Routine (ISR) to serve the device. After this, the MCU returns back to the interrupted program by loading the return address from the stack to the Program Counter. Interrupts can be enabled or disabled dynamically and when multiple interrupts come simultaneously priorities can be assigned. R S Ananda Murthy Interrupts in Atmega328P
  • 6. Interrupt Example R S Ananda Murthy Interrupts in Atmega328P
  • 7. Default Interrupt Vectors in Atmega328P R S Ananda Murthy Interrupts in Atmega328P
  • 8. Interrupt Vectors in Atmega328P Interrupt vector is a definite address in the program memory where a JMP instruction should be written to jump to the ISR corresponding to the interrupt. Each interrupt vector occupies two program memory words in order to provide space for JMP instruction. In Atmega328P, the RESET Vector is affected by BOOTRST fuse and the Interrupt Vector start address is affected by IVSEL bit in the MCUCR. R S Ananda Murthy Interrupts in Atmega328P
  • 9. Enabling and Disabling Interrupts in Atmega328P In SREG if I = 1, then all interrupts are enabled. We can make I = 1 by using SEI instruction in ALP and sei() function in C program. In SREG if I = 0, then all interrupts are disabled. We can make I = 0 by using CLI instruction in ALP and cli() function in C program. Upon reset I = 0 so all interrupts are disabled. R S Ananda Murthy Interrupts in Atmega328P
  • 10. Bits of EICRA Control Nature of INT1 and INT0 Bits 7, 6, 5, and 4 are not used and are always read as 0. R S Ananda Murthy Interrupts in Atmega328P
  • 11. Bits of EIMSK Mask/Unmask INT1 and INT0 Masking/unmasking means disabling/enabling respectively. When INT1 = 1 INT1 is unmasked if I = 1 in SREG. When INT1 = 0 INT1 is masked even if I = 1 in SREG. When INT0 = 1 INT0 is unmasked if I = 1 in SREG. When INT0 = 0 INT0 is masked even if I = 1 in SREG. Activity on the pins of INT1/INT0 will cause an interrupt request even if the corresponding pins are configured as output pins. Bits 2 to 7 are unused and will always be read as 0. R S Ananda Murthy Interrupts in Atmega328P
  • 12. Bits of EIFR Show Status of INT1 and INT0 Bits 2 to 7 are unused and will always be read as 0. When INT1 interrupt is triggered, INTF1 becomes 1. This flag is cleared when ISR is executed. When INT0 interrupt is triggered, INTF0 becomes 1. This flag is cleared when ISR is executed. INTF1/INTF0 flags can be cleared by writing a logical 1 to the respective bit. INTF1/INTF0 flags are always cleared when the respective interrupts are configured as a level interrupt. R S Ananda Murthy Interrupts in Atmega328P
  • 13. C-Code to use INT0 R S Ananda Murthy Interrupts in Atmega328P
  • 14. Problem Statement to use INT0/INT1 Assume that a push button is connected to the INT0/PD2 pin of Atmega328P MCU with internal pull-up resistor enabled and that a 7-segment common cathode display is connected to PORTB lines of the MCU through 330Ω current limiting resistors. Let a high-to-low logic change on this pin cause an INT0 interrupt. Sketch a diagram showing the hardware connections. Write a program in C which displays on the LED display any integer in the range 1 to 6, both inclusive, when ever the push button is pressed, thus simulating throwing of a die. Sketch a flow chart to show the logic. Also write ALP to achieve the task mentioned above. Modify the programs written above to use INT1/PD3. R S Ananda Murthy Interrupts in Atmega328P
  • 15. License This work is licensed under a Creative Commons Attribution 4.0 International License. R S Ananda Murthy Interrupts in Atmega328P