2023 Fall Microcomputer Laboratory Exp 1
2023 Fall Microcomputer Laboratory Exp 1
Laboratory
Experiment # 1 MPLAB X
IDE & Simulator
2023 Fall
OBJECTIVE
The objective of this experiment is to practice and verify the basics of building project
on MPLAB X IDE v5.00 The following chapter will cover required information about MPLAB X
IDE v5.00 .
PROCEDURE
Creating A Project
1. Create a new project using File -> New Project and select Microchip Embedded –
Standalone Project , as shown in New Project window. Then click next button. Select
Device window will appear.
2. Choose Mid range 8-bit MCUs in family section and select PIC16F877A in device
section. Then click next button. Select Tool window will appear.
3. Through this lab two options will be used; Simulator and PICkit2. In simulator mode,
registers’ content can be viewed in binary, hexadecimal and decimal types. It’s useful
to work on simulator first. In PICkit2 mode, in circuit debugging can be used on training
kits. For this experiment choose simulator. Then click next button. Select Compiler
window will appear.
4. Although, different compilers can be installed, in this course default compiler mpasm
will be used. Choose mpasm and click next button to proceed. Select Project Name
and Folder window will appear.
5. Write a valid project name i.e. “Experiment_1” and choose “D:” drive for project
location. Then click finish button.
6. Create a new file by right clicking Source Files on the project window and left click on
New and then Other. New File window will appear.
7. Choose Assembler and AssemblyFile.asm then click next. In the next window write a
valid name for assembly file then click finish button. Process of creating a new project
is completed.
Assembly Code
Copy this code into the created assembly file and compile it (you should see Build
Successful prompt).
banksel TRISD
clrf TRISD ;content of TRISD is cleared. Pins of PORTD
;register are selected as output.
banksel sayi3
movf sayi3,W ;content of sayi3 is transferred into
;working register.
banksel PORTD
clrf PORTD
movwf PORTD ;PORTD is equal to result of the addition.
end ;with this line program ends.
1. Compile the assembly code by clicking hammer & broom symbol. If there isn’t any
syntax error, “BUILD SUCCESSFUL” prompt will be appeared.
2. Click Debug Main Project button to start simulation. Simulation will be on running
mode.
3. Pause the simulation with pause button and then click reset button to start
the code from the beginning. Simulation can be run, step by step with step into button
.
4. Content of the registers can be viewed on Variables tab by creating watches. Add new
watches by clicking Create New Watch button . New Watch window will be
appeared.
5. The registers defined by the user can be added by using their addresses, i.e. sayi1 is
added.
6. Special function registers can be added by selecting SFR’s, i.e. PORTD is added.
7. In the end of the program, contents of the registers are shown in the figure below.
Project tool can be changed by using Run -> Set Project Configuration -> Customize
selection. After this selection choose hardware tool as PICkit2. Now experiment set can be
used with MPLAB X IDE.
Stimulus
1. Input signals can be stimulated in the simulator by using Window -> Simulator ->
Stimulus. Stimulus tab will be appeared below editor page.
2. Add clock stimulus in clock stimulus tab by using add a row button. Choose desired
pin and other properties. In debugging mode apply stimulus with apply synchronous
stimulus button.