Laboratory 2 Name: - : Dept. of Electronic Engineering EE302 - John Maloco
Laboratory 2 Name: - : Dept. of Electronic Engineering EE302 - John Maloco
of Electronic Engineering
Laboratory 2
INSTRUCTIONS
Name:____________________
This laboratory should be completed within the 3 hours allocated and handed up at the end of the lab. Be sure to include your name on all your work. Part 1 of the Laboratory exercise should be answered in the space provided. Be sure to include a printout of your source code with your answers. Dont forget to include your name. Copying will be penalised DETAILS Figure 1 below depicts a basic configuration of an embedded system based around the PIC16F877. The circuit consists of the following: Fosc : SW1 : SW2: LCD : Vdd
1
MCLR Vdd
9
4 Mhz Xtal
SW 1
PIC16F877
OSC2 RB0 RA4
10
15pF
SW 2
Vss Vss
19
2x16 LCD Display
Vss Figure 1
0V
Embedded and Realtime Systems The desired function of the circuit is as follows: 1. On start up display a title on both lines of the LCD display i.e. Laboratory 2 EE302
2.
When SW1 is pressed a button pressed counter is incremented once per button press up to a maximum of 99. Each increment should be displayed on the LCD i.e. Button Press = xx
3.
When SW2 is pressed a button pressed counter is decremented once per button press down to a minimum of 0. Each decrement should be displayed on the LCD i.e. Button Press = xx
4.
Laboratory Exercise 1. Using Pseudo code, outline the design of the program for the above. (20 marks) 2. Using MPLAB create a project and write the C program for the above. Include good comments and a title section for your code. (50 marks) 3. Download your program to the PICDEM 2 board and verify the function of the program using the ICD2 debugger. Demonstrate your working program to a lab demonstrator. (30 marks)
Notes: 1. The ICD2 debugger only allows one breakpoint to be inserted at a time. 2. After creating a project in MPLAB ensure that the configuration bits are set either in the code or in MPLAB. NOT BOTH.
Answer to Laboratory Exercise 3 Show lab demonstrator software working on PICDEM2 board. Lab demonstrator to sign off on this: