Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Experiment 1 . Introduction In this experiment, you are expected to create a project, compile and simulate it in MPLAB for PIC 1 8 F
Experiment Introduction
In this experiment, you are expected to create a project, compile and simulate it in MPLAB for
PICF Microcontroller. You need to use the same process in all future labs so it is important to
gain a solid understanding of the process and MPLAB.
Step I. Create a Project
Start MPLAB
Select menu FileNew Project; in the pop up window :
Select Categories "Microchip Embedded" and Projects "Standalone Project", Click Next
Select Advanced bit MCUs from Family list and "PICF from Device list, Click
Next
Click Next
Select Simulator from the Tools Menu, Click Next
Select mpasmvC:P from the Compile Toolchains, Click Next
Enter Project Name, Location and folder, check Set as main project click Finish
Note: It is recommended that you create a new project directory for each new lab experiment to
avoid the most common problem of including old files in new projects.
Step II Add a Source File
Once project is created, new window pops up on the upper left subwindow rightclick on Source
Files under your project name and select New AssemblyFile.asm
Note: If AssemblyFileasm is not found then click on Other in the pop up window, click on
assembler under categories and then select AssemblyFileasm under file types. Enter a "File Name" of your choice. main.asm is always a good choice, but you can choose
something more descriptive if you like. Don't enter anything in the Folder: area. You should see a
full path under "Created File:" which should end with mainasm", Click "Finish"
Computer Organization and Microprocessors ENGR Version Page
wwwEngrCS.com
Note: On the uppermiddleright side of the window should be a tab labeled "main.asm" This is
where you'll enter your program's source code.
Copy the following code into the main.asm file created in the last step. Save your using menu
FileSave".
Note: All instruction must be indented. Labels and #define must start on column You can indent
entire sections of text by selecting the text and hitting Tab key. Enable Absolute Addressing
Right click on the project name and select Properties
Computer Organization and Microprocessors ENGR Version Page
wwwEngrCS.com
Click on mpasm Global Options
Click on Unlock if not grayed out
Click the checkbox for "Build in absolute mode"
Click OK
Step III. Assembling a Project
Select menu ProductionBuild Main Project to assemble the code.
Notes:
All instruction must be indented. Labels and #define must start on column You can indent entire
sections of text by selecting the text and hitting Tab key.
Select Absolute if prompted with Absolute or Relocatable code dialog box.
The lowerright window should have a tab labeled "Output LabBuild Load and the bottom of
that window should include the messages "BUILD SUCCESSFUL" and "Loading Complete." Any
messages in red indicate an error and messages in blue are warning. Both have to be investigated
and corrected before a successful assembly.
Disassembly listing can be generated by selecting menu item
WindowDebuggingOutputDisassembly Listing File
Note: This step is only required for the report. If the menu is grayed out not available then rightclick on the project name and select properties. In the property window, select Loading check
Load symbols... and Click on Apply After the change, you need to redo step to generate the
disassembled listing.
Step IV Initializing Simulator and Debugger
Use the simulation feature of MPLAB to test the functionality of your Project by following the steps
shown:
In your source code listing, click on the line number next to the code line that says
CLRF PORTA ; Initialize PORTA"
The entire line should turn red. This indicates that you've created a breakpoint at that line. Each time
the simulator is about to execute a line with a breakpoint, the simulator will pause and return control
to you.
Select menu "DebugNew Watch..." and under "Enter or Select Watch Expression" enter PORTA
and click OK remember that names like "PORTA" are casesensitive: "PORTA" is different from "PortA" Repeat this step for PORTB and WREG
Select menu WindowSimulatorStimulus" You'll see a new tab labeled "Stimulus." Click on the
area beneath "Pin" and select RAwhich specifies bit of PORTA Click on the box under Action
and select "Toggle."
Note: Toggle means invert the value from to and from to
Computer Organization and Microprocessors ENGR Version Page
wwwEngrCS.com
Select DebugDebug Main Project." Your main dialog box should now say something like:
i Launching
ii Initializing simulator
iii User program running
iv User program stopped
v Breakpoint hit at line in file
Step V Simulation and Debugging
In addition to Special Function Registers, you can watch General Function Registers such as location
x
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started