Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

ECEN 3213 Spring 2005 Lab 9: Keyboard and Display Interface with Interrupts, Assignments of Electrical and Electronics Engineering

Lab 9 of ecen 3213 spring 2005 course, focusing on using interrupts for keyboard input and displaying the corresponding hexadecimal digit on an lcd. Students are required to write an assembly program for a 4x4 matrix keyboard and use interrupts to scan data. The document also includes instructions on initializing the pioc register and setting up the interrupt vector.

Typology: Assignments

Pre 2010

Uploaded on 03/19/2009

koofers-user-2k9
koofers-user-2k9 🇺🇸

10 documents

1 / 3

Toggle sidebar

Related documents


Partial preview of the text

Download ECEN 3213 Spring 2005 Lab 9: Keyboard and Display Interface with Interrupts and more Assignments Electrical and Electronics Engineering in PDF only on Docsity! ECEN 3213 Spring 2005 Lab 9 Due in Lab Section, Apr. 25, 27 Objective. Keyboard and Display Interface with Interrupts. Discussion. In the previous lab, the microcomputer was forced to continuously monitor the keyboard input. If the microcomputer has other tasks and keyboard input is relatively infrequent compared to these tasks, then an alternative technique is to use interrupts. Caution: inter- rupts are very difficult to debug because the software does not directly control when and in what order the interrupt service routines are executed. Interrupts are seldom absolutely necessary in embedded systems applications and should not be your first design choice. However, interrupts can be useful in many situations and you should be familiar with them should you decide to use them. The scan routine from the previous lab can be used to read the keyboard. You could use it as a subroutine called by your interrupt service routine. However, we need a signal from the keyboard to trigger the interrupt when any key is pressed regardless of where the key is in the switch matrix. This signal is provided by “anding” the column outputs of the switch matrix together as shown on p. 436 of Valvano. TeXaS simulates the “anding” hardware and provides an extra output from the keyboard. The STRA interrupt is the only one simulated correctly by TeXaS. STRA is a valid pin name recognized by TeXaS for the physical STRA input pin on the real 6811 package. Connect the “and” output from the keyboard columns to STRA by typing “STRA” in the port connection box next to the “and” gate output (click on the IO window, click on the IO menu at the top of the screen, click on keyboard and the keyboard port connection menu should appear). You can leave the other connections to the keyboard as in the previous lab. To read the keyboard, we output a 0 to each row, one row at a time. If a key is pressed, a 0 is produced on the column line. The output of the “and” gate is a 0 whenever any of its inputs are 0. Thus, we get a 0 on STRA whenever any key is pressed in the selected row. No change to STRA will occur when keys are pressed in rows that are not selected. The solution is to select all rows in the keyboard at once. Ouput a 0 to each row at the same time. You must initialize the rows at the beginning of your main routine (before enabling interrupts) so that you will be able to detect pressing any key when interrupts are enabled. ECEN 3213 Spring 2005 Lab 9 April 18, 2005 page 1 of 3 Do not forget to re-initialize the rows after scanning the keyboard in your interrupt service routine! The software interacts with the STRA interrupt through a special hardware register called PIOC (input/output control port?). On the 68HC711E, the PIOC is at address $1002. You should leave all the bits in the PIOC at 0 except the following three bits. bit 7: STAF automatically set 1 by hardware when edge occurs on STRA pin bit 6: STAI 1 = enable STRA interrupt; 0 = disable STRA interrupt bit 1: EGA 1 = set STAF on rising edge of STRA; 0 = set STAF on falling edge of STRA Your initialization code should clear STAF, set STAI to enable the STRA interrupt and clear EGA since the “and” keyboard output produces a 0 on STRA when a key is pressed. Do not forget that your initialization code must also clear the I-flag interrupt enable bit (cli instruction). When the STRA interrupt occurs, the microcomputer has to know where to find your interrupt service routine (interrupt handler). The 6811 uses special reserved memory loca- tions to store interrupt vectors for each interrupt type. We have already been doing this by storing the address for our main routine in the reset interrupt vector at $FFFE. The inter- rupt vector for the STRA interrupt is at $FFF2. When any interrupt occurs, the 6811 hardware automatically disables interrupts by forcing the I-flag to 1 before starting the interrupt service routine. It also automatically re-enables interrupts by forcing the I-flag back to 0 when the rti instruction is executed. You do not need any explicit instructions in the interrupt service routine to manipulate the I-flag. When the STRA interrupt occurs, the STAI interrupt enable bit is not automatically dis- abled by the hardware. The safest procedure is to explicitly disable the STAI bit and reset the STAF bit at the beginning of the interrupt service routine. Do not forget to re-enable the STAI bit before the rti instruction! Program Specifications. Write an assembly program (use subroutines as you wish) that uses interrupts to scan data from a 4x4 matrix keyboard with keys labeled “0”, “1”, ..., “9”, “A”, ..., “E” and “F”. The corresponding hexadecimal digit should appear in the right most (least significant) digit of the LCD output device. Previously entered digits should be shifted to the left in the 3-digit display (the sign and hexadecimal point will not be used). The display should not be changed if multiple keys are pressed. Also, the display should only change once when a single key is pressed. You may use any pin on any port that is appropriate to monitor the keyboard and drive the LCD. Reset should initialize the LCD to display 000.ECEN 3213 Spring 2005 Lab 9 April 18, 2005 page 2 of 3
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved