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

Embedded Software Design (EC242) : 2 Year - 2 Semester Lab 01

This document provides instructions for a lab exercise on writing and simulating assembly language programs for PIC16F microcontrollers using MPLAB IDE. The objectives are to write simple PIC assembly programs, create MPLAB projects, and simulate programs. Students are instructed to create a project folder, write an assembly code program, import the code into MPLAB, build and simulate the project, set breakpoints, and observe variable values after each instruction to understand how operations like MOVLW, MOVWF, ANDWF, etc. work. Students are also advised to maintain a thorough lab notebook.

Uploaded by

Gamindu Udayanga
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views7 pages

Embedded Software Design (EC242) : 2 Year - 2 Semester Lab 01

This document provides instructions for a lab exercise on writing and simulating assembly language programs for PIC16F microcontrollers using MPLAB IDE. The objectives are to write simple PIC assembly programs, create MPLAB projects, and simulate programs. Students are instructed to create a project folder, write an assembly code program, import the code into MPLAB, build and simulate the project, set breakpoints, and observe variable values after each instruction to understand how operations like MOVLW, MOVWF, ANDWF, etc. work. Students are also advised to maintain a thorough lab notebook.

Uploaded by

Gamindu Udayanga
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Embedded Software Design (EC242)

B.Sc. Special Honours Degree in Information Technology (Computer Systems & Networking)

2nd Year 2nd Semester Lab 01

Objectives
After completing this lab you will be able to; 1. Write simple assembly language programs to run on PIC16F microcontrollers. 2. Describe the procedure of creating a project in MPLAB IDE to program PIC16F microcontrollers. 3. Simulate a simple assembly language program using MPLAB IDE and PIC SIMULATOR IDE. 4. Explain the usage of header files in MPLAB projects.

Important You are advised to keep a proper lab notebook to takedown; Code segments you develop during the lab sessions Important facts related to the software and hardware tools used or the lab exercises Calculations performed And any other useful facts.

This notebook will be helpful for you to perform well in the lab assignments to be done in the last 5/6 weeks of the semester. Also this notebook will help you to prepare well for the examinations.

Page 1 of 7

Exercise
Create a new folder in D:\ pic or Z:\pic and name it as lab1_exe1 Open note pad and type the following code and save it as main.asm in the created folder. ;Declaration and configuration of the processor LIST P=16F877A #include p16F877A.inc ;include the header file num1 equ h'26' num2 equ h'27' num3 equ h'28' org 0x00 ;the reset vector goto main main ;putting the value 0xF0 to num1 movlw 0xF0 movwf num1 ;Using AND operation of num1 to mask bits movlw 0x5F andwf num1,f ;using OR operation on num2 to set bits movf num1,w iorwf num2,f ;using X-OR operation on working register to toggle bits movlw 0x01 clrf num3 xorwf num3,f xorwf num3,f endmain goto endmain end

Start -> All programs -> microchip -> MPLAB IDE 7.30 -> MPLABIDE Once MPLAB is open go to project-> project wizard Page 2 of 7

Click next and select the device as 16F877A

Select the Microchip MPASM tool suite. Page 3 of 7

Enter the project name as lab1_exe1 and select the directory where the main.asm file is saved.

Add the main.asm file and select it.

Page 4 of 7

Click finish. Add the header file C:\program files\MICROCHIP\MPAS suit\P16F877A.inc Build the project by clicking Change the movlw in line 17 to mov and check the output once built. You can go to the error line by clicking on the error message. Select the MPLAB SIM in the debugger.

The following bar appears. The first button is to run the code the next is to pause the execution. The 3rd button will go through each instruction. The 4th button will allow the user to go through each instruction and go inside subroutines. The 5th button will allow the user to

Page 5 of 7

go through each instruction and execute subroutines with one click. The 6th button will allow the user to come out from a subroutine. The last button will reset the MCU. Use the breakpoint function and set a breakpoint and see what happens. Open the stopwatch in the debugger menu and measure the time.

Open the watch window in the view tab and add the 3 variables num1,num2 and num3 and the working register.

Find out the values of num1, num2, num3 and working register after each instruction.

Page 6 of 7

Num1 movlw 0xF0 movwf num1 movlw 0x5F andwf num1,f movf num1,w iorwf num2,f movlw 0x01 clrf num3 xorwf num3,f xorwf num3,f

Num2

Num3

WREG

Describe the operation of the below instructions. movlw movwf andwf movf iorwf movlw clrf xorwf In order to check how the program responds to external outputs use the stimulus controller in the debugger menu. Update your lab notebooks.

Page 7 of 7

You might also like