0% found this document useful (0 votes)
63 views14 pages

Lab 1

This document provides instructions for a lab assignment introducing students to the QwikFlash microcontroller board, MPLAB X IDE, and C programming for PIC microchips. The lab has two parts: the first introduces MPLAB X IDE and simulating code, and the second has students write and run a "Hello World" program on the QwikFlash board to display a message and incrementing number on the LCD module. For their report, students are asked to explain the purpose of the Initialize_PIC() function and the process of printing to the LCD module.

Uploaded by

selva
Copyright
© © All Rights Reserved
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)
63 views14 pages

Lab 1

This document provides instructions for a lab assignment introducing students to the QwikFlash microcontroller board, MPLAB X IDE, and C programming for PIC microchips. The lab has two parts: the first introduces MPLAB X IDE and simulating code, and the second has students write and run a "Hello World" program on the QwikFlash board to display a message and incrementing number on the LCD module. For their report, students are asked to explain the purpose of the Initialize_PIC() function and the process of printing to the LCD module.

Uploaded by

selva
Copyright
© © All Rights Reserved
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/ 14

CSE 3442/5442: Embedded Systems

Lab 1: Introduction to the QwikFlash Board

Objective:
The purpose of this lab assignment is to familiarize with:
1. QwikFlash board (which is a PIC18F452 microcontroller chip based board
with various I/O devices.)
2. MPLAB X IDE used to create PIC microchip code programs and build ‘.hex’
that will run in PIC chip.
3. XC8 is a C compiler for PIC chips.
4. The PICKit3 is the programmer used to upload your program to the PIC.

Part 1: MPLAB X IDE and XC8 Compiler


This part will introduce MPLAB X IDE

1. Copy ‘Lab1_example_1.c’ program from the ‘CSE3442 files’ folder located in the
embedded M: server to your Z: drive. Open MPLABX IDE.

2. Select Create New Project


3. Choose Microchip Embedded > Standalone Project. Click Next.

4. Choose PIC18 family, PIC18F452 device. Click Next.


5. Choose the Simulator as your hardware tool. Click Next.

6. Choose the XC8 Compiler. Click Next.


7. Use Project_1 as your project name.
Project location should be Z:\YourNetID (most likely is Z drive)
Project folder should be Z:\YourNetID\Project_1.x
Click Set as main project.
8. Copy the ‘Lab1_example_1.c’ file to your Project_1.x folder.

9. Right-click Source Files. Select Add Existing Item…

10. Select the .c file. Click Select.


11. You can now double click the .c file to view/edit the code in the MPLABX IDE.

12. Select Run > Build Main Project


13. In the output console you should see BUILD SUCCESSFUL and Loading
completed. The .hex file (which is the only file you upload to a PIC) has now
been created, but we will not physically upload it to the PIC for this example.
We will instead use the Simulator to mimic the PIC’s capabilities completely
within the desktop computer.

14. Open up the following windows.


a. Watch (Window > Debugging > Watches)
b. Special function Registers (Window > PIC Memory Views > SFRs)
c. Logic Analyzer (Window > Simulator > Analyzer)
d. Stimulus (Window > Simulator > Stimulus)

15. You may now set various breakpoints within the C code, run the debugger
simulation (Debug > Debug Main Project), and Step Into (F7) a line-by-line
execution of the program.

16. Play around with the windows/watches opened up in Step 15 and see ports,
registers, variables, etc. change values as you are stepping through the code.
You may also use the Stimulus to imitate physical changes to the PIC’s input
pins on PORTB and PORTD.

If you have any questions/issues call the TA, if not you can move on to part 2.
Part 2: ‘Hello, World!’ program

The purpose of this part is to get familiar with running PIC programs using the
QwikFlash board. The code will display a message on the LCD along with an
incrementing number.

1. Copy ‘Lab1_example_2.c’ program from the ‘CSE3442 files’ folder located in the
embedded M: server to your Z: drive. Open MPLABX IDE.

2. Select Create New Project


3. Choose Microchip Embedded > Standalone Project. Click Next.

4. Choose PIC18 family, PIC18F452 device. Click Next.


5. Choose the PICkit3 (or serial # right below) as your hardware tool. Click Next.

6. Choose the XC8 Compiler. Click Next.


7. Use Project_2 as your project name.
Project location should be Z:\YourNetID (most likely is Z drive)
Project folder should be Z:\YourNetID\Project_2.x
Click Set as main project.
8. Copy the ‘Lab1_example_2.c’ file to your Project_2.x folder.

9. Right-click Source Files. Select Add Existing Item…

10. Select the .c file. Click Select.


11. You can now double click the .c file to view/edit the code in the MPLABX IDE.

12. Select the button Make and Program Device Main Project.

13. In the output console you should see a success message indicating that your
program was uploaded to the PIC.

There should now be a message and an incrementing number displayed


on the QwikFlash Board’s LCD Module.

IMPORTANT: Execute the “QwikFlash_Reset.bat” file in the shared M: drive. This code
will overwrite the PIC so no student code is left behind. Do this at the end of every lab
throughout the semester.
Assignment:
Write a lab report (using a word processor, submit as pdf) discussing the following:

1. What is the purpose of the function void Initialize_PIC()? How does this
function relate specifically to the QwikFlash board?

2. Explain the process of printing characters to the LCD module in the function
void Print_To_LCD(const char * tempPtr).

You can use reference materials for help on the two questions on the class webpage
http://omega.uta.edu/~nbb0130/CSE3442.html (Chapter-7 of Embedded Design…,
QwikFlash Board Schematic, etc.)

Submit your report via BlackBoard before the beginning of the next lab (one week).

You might also like