Program Specifications, Program Demonstration - Lab 8 - Spring 2005 | ECEN 3213, Lab Reports of Electrical and Electronics Engineering

Material Type: Lab; Professor: Johnson; Subject: Electrical and Computer Engineering ; University: Oklahoma State University - Stillwater; Term: Spring 2005;

Typology: Lab Reports

Pre 2010

Uploaded on 11/08/2009

koofers-user-nx5-1
koofers-user-nx5-1 ๐Ÿ‡บ๐Ÿ‡ธ

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ECEN 3213 Spring 2005 Lab 8 March 23, 2005 page 1 of 3
ECEN 3213
Spring 2005
Lab 8
Due in Lab Section, Apr. 4, 6
Objective.
Keyboard and Display Interface.
Discussion.
Connecting a single switch to an input pin is not feasible when there are a large number of
switches, such as in a keyboard. For example, a typical typewriter keyboard has several
dozen keys, each implemented as a contact switch. We do not usually have enough input
port pins to connect to each key in the keyboard. Instead, we must use the I/O port pins to
control more than one key/switch.
One way to make the use of I/O pins more efficient is to put the keys/switches in a two
dimensional matrix as shown in Valvano, Fig. 8.25, p. 436. A low (0) signal is driven onto
each row line one at a time. If no key is pressed (no switch closed), then the column lines
will remain high (1). If a single key is pressed, then one of column lines will go low (0).
A key can be identified by its unique combination of row and column lows.
An assembly program to scan the keyboard is provided in Program 8.11, p. 437-8. It relies
on the CWOM feature for the 6811 microcontroller. This feature appears not to work cor-
rectly on the TExaS simulator. The following subroutine is recommended instead. It is a
combination of the 6811 and 6812 code that works on the 6811. The following uses
PORTC since bits 6 and 7 of PORTD are not functional on the 6811.
;Table for scanning 4 x 4 keyboard
;keys should be labeled as
; 1 2 3 4
; 5 6 7 8
; 9 A B C
; D E F 0
scantab:;most significant nibble has hex digit
db %01110000 PORTC for PC7 row
db %10000000 DDRC for PC7 row
db $10,$20,$30,$40
db %10110000 PORTC for PC6 row
db %01000000 DDRC for PC6 row
db $50,$60,$70,$80
db %11010000 PORTC for PC5 row
db %00100000 DDRC for PC5 row
db $90,$A0,$B0,$C0
db %11100000 PC4 row
db %00010000 DDRC for PC4 row
db $D0,$E0,$F0,$00
db $00 end of table marker
pf3

Partial preview of the text

Download Program Specifications, Program Demonstration - Lab 8 - Spring 2005 | ECEN 3213 and more Lab Reports Electrical and Electronics Engineering in PDF only on Docsity!

ECEN 3213

Spring 2005

Lab 8

Due in Lab Section, Apr. 4, 6

Objective.

Keyboard and Display Interface.

Discussion.

Connecting a single switch to an input pin is not feasible when there are a large number of

switches, such as in a keyboard. For example, a typical typewriter keyboard has several

dozen keys, each implemented as a contact switch. We do not usually have enough input

port pins to connect to each key in the keyboard. Instead, we must use the I/O port pins to

control more than one key/switch.

One way to make the use of I/O pins more efficient is to put the keys/switches in a two

dimensional matrix as shown in Valvano, Fig. 8.25, p. 436. A low (0) signal is driven onto

each row line one at a time. If no key is pressed (no switch closed), then the column lines

will remain high (1). If a single key is pressed, then one of column lines will go low (0).

A key can be identified by its unique combination of row and column lows.

An assembly program to scan the keyboard is provided in Program 8.11, p. 437-8. It relies

on the CWOM feature for the 6811 microcontroller. This feature appears not to work cor-

rectly on the TExaS simulator. The following subroutine is recommended instead. It is a

combination of the 6811 and 6812 code that works on the 6811. The following uses

PORTC since bits 6 and 7 of PORTD are not functional on the 6811.

;Table for scanning 4 x 4 keyboard ;keys should be labeled as ; 1 2 3 4 ; 5 6 7 8 ; 9 A B C ; D E F 0 scantab: ;most significant nibble has hex digit db %01110000 PORTC for PC7 row db %10000000 DDRC for PC7 row db $10,$20,$30,$ db %10110000 PORTC for PC6 row db %01000000 DDRC for PC6 row db $50,$60,$70,$ db %11010000 PORTC for PC5 row db %00100000 DDRC for PC5 row db $90,$A0,$B0,$C db %11100000 PC4 row db %00010000 DDRC for PC4 row db $D0,$E0,$F0,$ db $00 end of table marker

;scan keyboard, no registers preserved ;hex digit returned in high nibble of A-reg ;number of keys pressed returned in Y-reg scan ldy #0 initial number pressed ldx #scantab sloop ldb 0,x beq sdone check for end of table stb PORTC select row ldb 1,x stb DDRC ldb PORTC read column lsrb PC0 into carry bcs not lda 5,x load key value into a iny inc y for a key detected not0 lsrb PC1 into carry bcs not lda 4,x load key value into a iny inc y for a key detected not1 lsrb PC2 into carry bcs not lda 3,x load key value into a iny inc y for a key detectedsdonerts not2 lsrb PC1 into carry bcs not lda 2,x load key value into a iny inc y for a key detected not3 ldb #6 scantab entry size abx inc x to next row bra sloop sdone rts

The same arguments can be made for more efficient use of output ports for driving LEDโ€™s.

The simulator provides a very simple interface to a seven segment LCD. Instead of con-

trolling each of the seven segments directly, a 4-bit hexadecimal digit is translated into the

correct seven segment display that resembles the hexadecimal digit. One quirk of the sim-

ulation is that only the low nibble (pins 3-0) or the high nibble (pins 7-4) of an output port

can be used to display a hexadecimal digit. This makes it impossible to use PORTA on the

6811 do drive the LCD display.

Program Specifications.

Write an assembly program (use subroutines as you wish) that repeatedly scans data from

a 4x4 matrix keyboard with keys labeled โ€œ0โ€, โ€œ1โ€, ..., โ€œ9โ€, โ€œAโ€, ..., โ€œEโ€ and โ€œFโ€. The cor-

responding 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. The easiest way to achieve this is to allow

changes to the display only when the previous scan gave 0 keys pressed and the current

scan gives 1 key pressed.

You may use any pin on any port that is appropriate to monitor the keyboard and drive the

LCD.