0% found this document useful (0 votes)
14 views7 pages

Es Lab 07

The lab report focuses on the demonstration and application of interrupts in PIC microcontrollers, specifically using the PIC16F877A. The experiment aims to implement an LED flasher with a counter using interrupts, highlighting the importance of interrupts for efficient CPU management and multitasking. The report includes a detailed procedure, assembly code, and conclusions drawn from the experiment regarding the interrupt feature and its application in embedded systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views7 pages

Es Lab 07

The lab report focuses on the demonstration and application of interrupts in PIC microcontrollers, specifically using the PIC16F877A. The experiment aims to implement an LED flasher with a counter using interrupts, highlighting the importance of interrupts for efficient CPU management and multitasking. The report includes a detailed procedure, assembly code, and conclusions drawn from the experiment regarding the interrupt feature and its application in embedded systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Electrical Engineering Department

Embeded System Lab

AN INTURREPTS:DEMONSTRATION AND APPLICATION

Lab Report: 07

Submitted to:
Sir Asad Ur Rahman

Submitted by:
SAMI UL HAQ Reg No:220401029
UMER IMTIAZ Reg No:220401007
OBJECTIVES:
The objective of the experiment is to:
 Introduction of pic microcontroller interrupt structure and interrupt source.
 Implementation of LED flasher with counter by using interrupt.
THEORY:
Interrupt:
An interrupt is a powerful mechanism that allows a computer’s central processing unit
(CPU) to respond promptly to external events or hardware conditions. Here are some key
points about interrupts:
1. Asynchronous Events: Interrupts occur asynchronously, meaning they can happen
at any point during the execution of the main program. Unlike regular function
calls, which are explicitly invoked by the program, interrupts are triggered by
external events.
2. Peripheral Hardware Management: Imagine a PC with various peripheral devices—
keyboard, mouse, hard drive, real-time clock, printer, and modem. These
peripherals are managed and maintained by the operating system through an
interrupt mechanism. When a peripheral needs attention (e.g., a keypress or data
transfer), it signals the CPU via an interrupt request.
3. Multitasking and Efficiency: Interrupts enable multitasking. While the CPU handles
one task, it can quickly switch to another task when an interrupt occurs. This allows
efficient utilization of processing time. For example, a computer can process
keyboard input while simultaneously updating the display.
4. Interrupt Service Routine (ISR): When an interrupt occurs, the CPU automatically
switches execution to an ISR. The ISR is a specialized subroutine that handles the
specific event associated with the interrupt. It performs necessary actions (such as
reading data from a sensor or writing to a file) and then returns control to the main
program.
5. Thread-Based Model: Each interrupt request starts a new thread of execution. Local
variables and registers used in the ISR are specific to that interrupt event. Treating
each request as a separate thread ensures proper isolation and prevents interference
between different interrupts.
6. Interaction and Synchronization: In systems with multiple threads (including
interrupt threads), they work together to achieve larger goals. Mechanisms
like FIFO (First-In-First-Out) queues allow threads to interact and synchronize
effectively.
Interrupt Flags:
The Interrupt Flag (IF) is a bit in the CPU’s FLAGS register. Here’s how it works:
 When IF is set to 1, maskable interrupts are enabled. The CPU responds instantly to
hardware interrupts.
 If IF is reset (set to 0), maskable interrupts are disabled until explicitly re-enabled.
Embedded Systems:
An embedded system is a specialized computer system designed to perform a specific task
or function. Key characteristics include:
 Microcontroller or Microprocessor-Based: Embedded systems use microcontrollers
(small integrated circuits with CPU, memory, and I/O interfaces) or
microprocessors (more powerful CPUs) tailored for specific applications.
 Task-Specific: Each embedded system focuses on a particular task, such as
controlling a microwave oven, monitoring a heart rate, or managing a fire alarm.
 Integration: Embedded systems can be standalone or part of a larger system. They
often interact with sensors, actuators, and other hardware components.
 Efficiency: Embedded systems are optimized for efficiency, power consumption,
and reliability.
For instance, consider a fire alarm—an embedded system that senses smoke and triggers
an alarm. It operates independently, continuously monitoring its environment to ensure
safety.
EXERCIZE
TASK1:
Procedure:
 Writ code in MPLAB Software for a PIC16F877A.
 Compile the code to generate a .hex file containing machine instructions.
 Make a Proteus schematic with the PIC16F877A.
 Make circuit according code and make connection same as code.
 Load the compiled .hex file onto the PIC16F877A in the Proteus simulation.
 Run the Proteus simulation to see Result on LED bar.

CODE:
;//EQUATE SECTION//
PORTD EQU 08H
TRISD EQU 88H
PORTB EQU 06H
TRISB EQU 86H
INTCON EQU 0BH
option_reg EQU 81H
COUNT EQU 20H
COUNT1 EQU 21H
LIST P=16F877A ;//name of microcontroller
ORG 0 ;//adressing starts from zero
GOTO START ;//jumping to start
org 0x04;
__CONFIG H'3F79'
ISR
MOVLW H'FF'
MOVWF PORTD
CALL DELAY
MOVLW H'00'
MOVWF PORTD
CALL DELAY
MOVLW H'FF'
MOVWF PORTD
CALL DELAY
MOVLW H'00'
MOVWF PORTD
CALL DELAY;
BCF INTCON,1;
RETFIE;
;//DELAY FUNCTION//
DELAY
MOVLW .255
MOVWF COUNT
MOVLW .255
MOVWF COUNT1
A
DECFSZ COUNT,1
GOTO A
DECFSZ COUNT1,1
GOTO A
RETLW 0
;//PORT CNFIGURATION//
START
BANKSEL TRISD
MOVLW B'00000000'
MOVWF TRISD
MOVLW B'00000001'
MOVWF TRISB
BANKSEL INTCON
MOVLW B'10010000'
MOVWF INTCON
BANKSEL option_reg
Proteus Simulation:
MOVLW B'11000000'
MOVWF option_reg
BANKSEL PORTD
CLRF PORTD
CLRF PORTB
;//MAIN PROGRAM//
LOOP
MOVLW B'00000001'
MOVWF PORTD
CALL DELAY
MOVLW B'00000010'
MOVWF PORTD
CALL DELAY
MOVLW B'00000100'
MOVWF PORTD
CALL DELAY
MOVLW B'00001000'
MOVWF PORTD
CALL DELAY
MOVLW B'00010000'
MOVWF PORTD
CALL DELAY
MOVLW B'00100000'
MOVWF PORTD
CALL DELAY
MOVLW B'01000000'
MOVWF PORTD
CALL DELAY
MOVLW B'10000000'
MOVWF PORTD
CALL DELAY
MOVLW B'00000000'
MOVWF PORTD
CALL DELAY
GOTO LOOP
END
CIRCUIT:
Output with delay onward:
When Interruped(button pushed):

Conclusion:
 We learnt about the interrupt feature of Microcontroller and PIC interrupt feature.
 Learnt how to write and implement an assembly language code using the interrupt
feature, once for on all the LEDs.
 Got familiarized with the different sources of interrupt in PIC Microcontroller.

You might also like