Professional Documents
Culture Documents
FACULTY OF ENGINEERING
ELECTRICAL & ELECTRONICS ENGINEERING DEPT.
Instructor:
Assist. Prof. Dr. Mohammed ALKRUNZ
Electrical & Electronics Engineering Dept.
PIC16F84A- Interrupt
Interrupt is a mechanism of a microcontroller which enables it to respond to some
events at the moment they occur, regardless of what the microcontroller is doing at
the time.
Note: for each interrupt source, there are two corresponding pins: an Enable pin (to
activate the interrupt), and a Flag pin (to indicate that an interrupt occurred).
Dr. M. Alkrunz
31.10.2022 2
EEE471: Embedded System Design
PIC16F84A- Interrupt
Registers Used with Interrupt:
Dr. M. Alkrunz
31.10.2022 3
EEE471: Embedded System Design
PIC16F84A- Interrupt
“INTCON” Register
Dr. M. Alkrunz
31.10.2022 4
EEE471: Embedded System Design
PIC16F84A- Interrupt
“OPTION_REG” Register
This register is very important in this course, and we will take it in details in the topic of
TMR0. But, we are considering it in the topic of interrupt since it contains a pin related to
RB0/INT interrupt source type.
Dr. M. Alkrunz
31.10.2022 5
EEE471: Embedded System Design
PIC16F84A- Interrupt
“EECON1” Register
This register is very important in the topic of EEPROM. But, we care on one pin in the
interrupt topic here.
Note that All interrupt source flags are located on “INTCON” register except this one
here.
Dr. M. Alkrunz
31.10.2022 6
EEE471: Embedded System Design
PIC16F84A- Interrupt
How to make an Interrupt
Dr. M. Alkrunz
31.10.2022 7
EEE471: Embedded System Design
PIC16F84A- Interrupt
1) Enable the “GIE” pin (INTCON.GIE) which is the main enable bit for all interrupt
sources.
2) Enable the interrupt source type that you need. Activation is occurred by setting the
corresponding enable pin by “1” from the four sources (EEIE, T0IE, RBIE, INTE)
3) Now, the pic is ready for the waiting interrupt to be occurred. When the interrupt is
occurred, directly the corresponding flag will have a value of “1”. Therefore, it is very
important to reset the flag in the program of interrupt.
Dr. M. Alkrunz
31.10.2022 8
EEE471: Embedded System Design
PIC16F84A- Interrupt
Example 1:
Each click on the push button that connected to RB0 (interrupt source), a toggle on the
led which is connected to RB2 will be achieved.
Dr. M. Alkrunz
31.10.2022 9
EEE471: Embedded System Design
PIC16F84A- Interrupt
Example 2:
A flasher on RA0.
Use the interrupt method to control the flashing speed of this flasher.
Dr. M. Alkrunz
31.10.2022 10
EEE471: Embedded System Design
*Questions
Dr. M. Alkrunz
31.10.2022 11
EEE471: Embedded System Design
*Thanks
Dr. M. Alkrunz
31.10.2022 12
EEE471: Embedded System Design