Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

Lab 1 Introduction to Assembly Programming Language

The document outlines a laboratory exercise for students in the EC2132 Microcomputers course, focusing on programming the PIC16F877A microcontroller using assembly language. It includes objectives such as understanding assembly structure, implementing I/O control, and troubleshooting, along with specific tasks like controlling LEDs and creating a Knight Rider effect. The lab aims to provide practical experience in microcontroller operations relevant to embedded systems development.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lab 1 Introduction to Assembly Programming Language

The document outlines a laboratory exercise for students in the EC2132 Microcomputers course, focusing on programming the PIC16F877A microcontroller using assembly language. It includes objectives such as understanding assembly structure, implementing I/O control, and troubleshooting, along with specific tasks like controlling LEDs and creating a Knight Rider effect. The lab aims to provide practical experience in microcontroller operations relevant to embedded systems development.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

EC2132 – Microcomputers

Department of Electrical and Electronic Engineering Year 02, Semester 01


Faculty of Engineering
B.Sc. Eng. (Hons) 2024

Lab 1: Introduction to Assembly Programming Language LO3, LO4

1. Introduction
In this lab, students will learn how to program the PIC16F877A microcontroller using
assembly language. Through simple tasks such as controlling LEDs, integrating input
signals, and simulating the famous "Knight Rider" LED sequence, you will gain practical
experience with basic microcontroller I/O operations. The tasks are designed to develop
both your understanding and technical skills progressively.

2. Objectives

• Understand the basic structure of an assembly language program for PIC


microcontrollers.
• Comprehend the role of each instruction in the program and how they interact with the
hardware.
• Implement simple I/O control by programming the PIC16F877A using assembly code.
• Identify and troubleshoot errors in the simulation and the program.
• Assess the performance of the system with input signals and complex LED sequences.
• Develop and integrate complex control circuits using assembly code.

3. Apparatus

• Proteus simulation software.


• PIC16F877A microcontroller model.
• LED(s).
• Push button and toggle switch components.
4. Laboratory Tasks

Task 1: Lighting an LED

Objective: Program a PIC16F877A microcontroller to control an LED connected to one


of its output pins.

1.1 Turning ON an LED (Output Operation)

• Connect an LED to any one of the output pins of the microcontroller (e.g. PORTB0).

• Write Assembly Code: Write code to turn on the LED.


o Use BSF (Bit Set File) instruction to turn the bit high.
o Make sure to set the corresponding TRISB register for output.

• Simulate in Proteus: Load the hex file and check if the LED turns on.

1.2 Blinking the LED (Timing Control)

• Modify the code to blink the LED with a delay.


o Use CALL DELAY instruction for timing control.
o Create a delay subroutine to control the blink rate.

• Simulate in Proteus: Observe the blinking LED.


Task 2: LED Control with an Input Signal

Objective: Control the LED based on external inputs such as a push button or toggle
switch.

2.1 Using a Push Button to Start the LED

• Connect a push button to one of the input pins (e.g., PORTB1).

• Modify the code to turn on the LED only when the button is pressed.
o Use BTFSS (Bit Test File, Skip if Set) instruction to detect button press.

• Simulate in Proteus: Verify the LED turns on when the button is pressed.

2.2 Using a Toggle Switch to Start and Stop

• Connect a toggle switch to one of the input pins (e.g., PORTB2).


• Write code to turn on the LED when the switch is toggled ON and turn it off when
toggled OFF.

• Simulate in Proteus: Observe how the switch controls the LED.


Task 3: Building the Knight Rider Circuit

Objective: Create a sequential LED pattern using bit-rotating techniques and enhance
control with an input toggle switch.

3.1 Controlling LED Sequences with Bit-Rotating

• Connect multiple LEDs to PORTB (e.g., PORTB<7:0>).

• Write code to create a Knight Rider effect (LEDs light up one after another in a pattern).
o Use RLF (Rotate Left) or RRF (Rotate Right) instructions to create the
sequence.

• Simulate in Proteus: Ensure the LEDs light up in sequence, creating the Knight Rider
effect.

3.2 Integrating the Toggle Switch

• Modify the code so the Knight Rider sequence starts only when a toggle switch is
turned ON.
o Use conditional checks with BTFSS or BTFSC instructions.

• Simulate in Proteus: Check that the sequence only starts when the switch is ON.

5. Post-Lab Questions

1. What is the purpose of the TRIS register in PIC assembly programming?


2. Explain how the BSF and BCF instructions control the output pins.
3. How does the RLF instruction affect the LED sequence in the Knight Rider circuit?
4. How could you modify the code to make the LED blink faster or slower?
5. Discuss potential applications of bit-rotating in real-world embedded systems.

6. Conclusion

This lab introduces the fundamental principles of controlling hardware using assembly
programming for the PIC16F877A. You will learn about basic output control, input sensing,
and sequence generation using LEDs, which are common tasks in embedded systems
development.

You might also like