Docsity

ECGR 4101/5101 Lab 2: Simple Programmed I/O with QSK26A Board, Lab Reports of Electrical and Electronics Engineering

Toggle sidebar
bg1
ECGR 4101/5101 Spring 2008
Lab 2
Simple Programmed I/O
Due: 2/16/09, at 2:00pm. Assignment should be typed, a hard copy turned in to Lab TA. The
TA will be in the lab from 12:00-2:00pm on the due date (but you may turn it in any time
before the deadline). Use the template below to prepare your lab report.
Objectives
The goal of this lab is to introduce you to more of the peripherals available on the QSK board
and Programmed I/O.
Prelab Assignment
•Review Chapter 16 (Programmable I/O Ports) of M16C26A Hardware Manual.
•Review Section 5.2 (Block Diagram of QSK26A Board) in QSK26A User Manual.pdf.
•Review App Note and Sample Programs (on CD) for “Keyin IRQ” project.
Laboratory Procedure
You are to write a program that runs on your QSK26A board that moves a +character around
the LCD display. It is optional to use interrupts (as described below) and update the display
every time a button is pressed.
1. The QSK26A board has four push-button switches. We will be using S101 through S103.
(S104 is the reset switch.)
2. Find the switches on the board and on the block diagram in the board. Document in
your lab report the ports each switch is connected to.
3. Create a new project in HEW. You are to write a program that consists of at least two
routines, main and display. (You will need more if you choose to use three interrupt
service routines.) Your program will need to do the following.
(a) Create a struct that has two unsigned integer variables — xand y. Exactly one
global instance of this struct is to be declared. Main will set the initial x to 4, y to
0. (These represent the position of the + on the LCD display.)
(b) Set up the three ports; configuring them to be inputs and not outputs.
(c) (If needed, set up three interrupts; one interrupt service routine for each button.)
1
pf2

Partial preview of the text

Download ECGR 4101/5101 Lab 2: Simple Programmed I/O with QSK26A Board and more Lab Reports Electrical and Electronics Engineering in PDF only on Docsity!

ECGR 4101/5101 Spring 2008

Lab 2

Simple Programmed I/O

Due: 2/16/09, at 2:00pm. Assignment should be typed, a hard copy turned in to Lab TA. The TA will be in the lab from 12:00-2:00pm on the due date (but you may turn it in any time before the deadline). Use the template below to prepare your lab report.

Objectives

The goal of this lab is to introduce you to more of the peripherals available on the QSK board and Programmed I/O.

Prelab Assignment

  • Review Chapter 16 (Programmable I/O Ports) of M16C26A Hardware Manual.
  • Review Section 5.2 (Block Diagram of QSK26A Board) in QSK26A User Manual.pdf.
  • Review App Note and Sample Programs (on CD) for “Keyin IRQ” project.

Laboratory Procedure

You are to write a program that runs on your QSK26A board that moves a + character around the LCD display. It is optional to use interrupts (as described below) and update the display every time a button is pressed.

  1. The QSK26A board has four push-button switches. We will be using S101 through S103. (S104 is the reset switch.)
  2. Find the switches on the board and on the block diagram in the board. Document in your lab report the ports each switch is connected to.
  3. Create a new project in HEW. You are to write a program that consists of at least two routines, main and display. (You will need more if you choose to use three interrupt service routines.) Your program will need to do the following.

(a) Create a struct that has two unsigned integer variables — x and y. Exactly one global instance of this struct is to be declared. Main will set the initial x to 4, y to

  1. (These represent the position of the + on the LCD display.) (b) Set up the three ports; configuring them to be inputs and not outputs. (c) (If needed, set up three interrupts; one interrupt service routine for each button.)

(d) The display subroutine will blank the LCD display, then according to the position of the plus, display the plus at the appropriate place on the LCD screen. (e) In the header comments (bottom of the comment block), add a few lines stating your name, the date, and the purpose of each subroutine. (f) Add an appropriate comment to the procedure you changed that describes your intent. (What are the changes supposed to do?)

The behavior of the interrupts are as follows. If S101 is pressed, then the + moves one position to the left. If the + is already at the leftmost side of the screen x = 0, then it should wrap around to the rightmost side of the screen. If S103 is pressed, then the plus moves to the right. If it reaches the rightmost side of the screen, it wraps around as well. If S102 is pressed the + changes rows. If it was on row 0, it moves to row 1. If it was on row 1, it moves to row 0.

  1. Save project and test it on the board. (Review lab 1 if for details.)

Hints: (1) Your main program will need to have an infinite loop; after setting up every- thing, the interrupt service routines take care of the work. (2) You may want to develop your code incrementally. Start with the App Note and sample code, get one interrupt attached to one switch working. Use the LEDs to help you debug. Then develop the display code and logic for moving the +. (3) Use the sfr26a header files to make setting up the ports and interrupts easy. Complete your lab report and bring your board to the TA to demonstrate the new code. (Note: you do not need to start up HEW.) For the lab report, you do not need to print the entire program: just include printouts of the parts you changed.

Laboratory Report

Include in the checkout part of your lab report the lines:

  1. Switches move the + left and right
  2. S102 moves the + between rows
    • properly wraps around
  3. Code is using global structure
  4. Code is using polling or interrupts
  5. Code is properly commented/indented

Also, include as part of your lab report observations and procedures. Refer to lab 1 for what is expected in your report.