Lab Report #1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

King Abdulaziz University

Faculty of Engineering
Electrical-Computer Engineering Department

EE366 | Microprocessors and Microcontrollers


Lab Experiment #1
Introduction to MPLAB & Proteus

Section
EAG

Lab Time
Wednesday, 14:00–15:50

Submission Date

Wednesday, February 12th, 2020

Team Members

Haneen Alsaedi 1606278

Lana Joharji 1607588

Noura Aldakhil 1614549

Instructors
Dr Rania Elmanfalouty
Engineer Haneen
Table of Contents

Introduction ................................................................................................................................ 3

Objectives .................................................................................................................................. 3

Experiment ................................................................................................................................. 3

Schematic Diagram ................................................................................................................ 3

Source Code ........................................................................................................................... 4

Results ........................................................................................................................................ 5

Conclusion ............................................................................................................................... 10

References ................................................................................................................................ 10
Introduction
Assembly language commands are used to control all processing units. It performs the basic
arithmetic and logical operations performed by the computer’s processor. As for the
microcontroller, it is a single element which combines the components needed to act as a single
unit. The aim of this laboratory was to familiarize students with the software used for assembly
language, which is MPLAB, and the software used for hardware simulation, which is Proteus
VSM. Alternatively, using Proteus Design software to analyze the schematics of a PIC18F4550
microcontroller is implemented. Proteus is a widely used tool by engineers that simulates the
behavior of more than 800 types of microcontrollers as well as a variety of other utilities [1].

Objectives
• To gain understanding of Assembly programming language
• To gain an understanding of MPLAB IDE
• To examine and use MPLAB assembler
• To examine and use MPLAB simulator
• To examine and use Proteus VSM (Virtual System Modelling) for hardware simulation

Experiment
Schematic Diagram
For exercises one through four, no schematic diagrams were needed since the results were
obtained using MPLAB. However, exercise 5 required the use of Proteus, thus a schematic
diagram was given as shown in Figure 1. The results of the constructed schematic are shown
in the Results section.

Figure 1: Exercise 5 Schematic Diagram


Source Code
Since exercise 5 was executed using Proteus, the source codes for exercises 1 to 4 will only be
provided.

EXERCISE 1 EXERCISE 2

#include <p18f4550.inc> #include <p18f4550.inc>


org 0 org 0
Start: Start:
MOVLW 0xB3; Load literal B3H to WREG MOVLW 0x1; Load literal 1H to WREG
MOVWF 0x40; Move(copy) WREG Data to 40H ADDLW 0x3; Add literal 3H to WREG
MOVWF 0x41; Move(copy) WREG Data to 41H ADDLW 0x5; Add literal 5H to WREG
MOVWF 0x42; Move(copy) WREG Data to 42H ADDLW 0x2; Add literal 2H to WREG
MOVWF 0x43; Move(copy) WREG Data to 43H ADDLW 0x4; Add literal 4H to WREG
MOVWF 0x44; Move(copy) WREG Data to 44H
MOVWF 0x45; Move(copy) WREG Data to 45H GOTO $ ; Wait here
END
GOTO $ ; Wait here
END

EXERCISE 3 EXERCISE 4

#include <p18f4550.inc> #include <p18f4550.inc>


org 0 org 0
Start: Start:
MOVLW D'30'; Load literal 30D to WREG MOVLW O'3'; Load literal Octa 3 to WREG
ADDLW 0x3 ; Add literal 3H to WREG ADDLW O'2'; Add literal Octa 2 to WREG
MOVWF 0x40 ; Move(copy) WREG Data to 40H MOVWF 0x70; Move(copy) WREG Data to 70H
GOTO $ ; Wait here
GOTO $ ; Wait here END
END
Results
This lab contains five exercises, the first four were made with MPLABX and the last one was
made with Proteus. The first exercise was to write and assemble a program that moves the value
0xB3 to WREG register. Then move it from WREG to file register locations 40H to 45H. As
shown in Figure 2 a literal value of A3H was moved to WREG then the same value was moved
as a copy from the WREG to location 40H, then to 41H ,42H,43H,44H, 45H respectively.

Figure 2: Exercise 1
The second exercise we wrote and assembled a program to add 5 random single digits numbers
and save the result in WREG. As shown in Figure 3 we first moved literal value 1H to the
WREG, after that we used ADD instruction to add the numbers 1H, 3H, 5H, 2H, 4H finally the
value in the WREG was 0F H which represents 10 in decimal.

Figure 3: Exercise 2

The third exercise was to write and assemble a program to set the value 30 in decimal to WREG
register, and then increment it by 3 and copy it to File Register location 40H. As shown in
Figure 4 we moved literal value 30d to WREG then we add 3 to WREG. Finally, we moved a
copy from the WREG contents to location 40H as shown in Figure 5 the final value was 21 hex
which is equal to 33d.
Figure 4: Exercise 3 (WREG)

Figure 5: Exercise 3 (File register 40H)


The fourth exercise was to write and assemble a program to add two octal numbers then we
saved the result to file-register location 70H. As shown in Figure 6 we moved literal value 3o
to WREG then we add 2o to it. Finally, we moved a copy from WREG contents to location
30H as shown in Figure 7. and the result was 5o in both WREG and 70H.

Figure 6: Exercise 4 (WREG)

Figure 7: Exercise 4 (File register 70H)


The fifth exercise was to create a schematic using Proteus ISIS we connect a LED (RED) to
pin 15 and a 330 Ω resistor was connected to the led and to the ground. Finally, a 5V power
source was connected to pin 1 in the microcontroller. After we programmed our microcontroller
and ran the simulation the result is as shown in Figure 8 and 9 which was that the red led was
flashing on and off.

Figure 8: Schematic for PIC18F4550 with LED turned OFF


Figure 9: Schematic for PIC18F4550 with LED turned ON

Conclusion
In conclusion, the two tests were performed successfully, and the objectives were achieved.
Using the MPLAB software proved crucial in assembling and simulating commands as to the
program in a single step when analyzing the various variables. The results reflect accurate,
high-precision functional values. On the other hand, proving a PIC microcontroller's
performance using Proteus was simple and detailed. A clear understanding of both simulators
was obtained. All experiments show how interrelated they are. A computer simulation
framework like Proteus needs to simulate all microcontrollers and program them using
assembly language.

References

[1] [Online]. Available: https://www.labcenter.com.

You might also like