DOC PREVIEW
U of U ECE 3720 - LECTURE NOTES
Pages 5

This preview shows page 1-2 out of 5 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1'&$%ECE/CS 3720: Embedded System Design(ECE 6960/2 and CS 6968)Chris J. MyersLecture 6: Debouncing and Matrix KeypadsSlide 2'&$%Interfacing a Switch to a Computer1Slide 3'&$%Switch BounceSlide 4'&$%Hardware Debouncing Using a Capacitor2Slide 5'&$%Software DebouncingSlide 6'&$%Software Debouncing with Gadfly SynchronizationWaitPress: ldaa PORTA ;PA0=0 if pressedanda #$01bne WaitPress ;loop till pressedldd TCNTaddd #20000 ;10ms delaystd TOC5ldaa #$08staa TFLG1 ;clear OC5FloopP: ldaa TFLG1 ;10ms for bouncinganda #$08 ;OC5F set?beq loopPrts3Slide 7'&$%Applications of Output Compare• Can create a fixed time delay.1. Read the current 16-bit TCNT2. Calculate TCNT+fixed3. Set 16-bit output compare register to TCNT+fixed4. Clear the output compare flag5. Wait for the output compare flag to be set• Delay of steps 1 to 4 sets the minimum delay.• Maximum delay is 65,536 cycles.Slide 8'&$%Output Compare Interface on 68HC114Slide 9'&$%Control Bits and FlagsOMn OLn Effect of when TOCn=TCNT0 0 Does not affect OCn0 1 Toggle OCn1 0 Clear OCn=01 1 Set OCn=1Slide 10'&$%Software Debouncing with Gadfly SynchronizationWaitRel: ldaa PORTA ;PA0=1 if releasedanda #$01beq WaitRel ;loop until releasedldd TCNTaddd #20000 ;10ms delaystd TOC5ldaa #$08staa TFLG1 ;clear OC5FloopR: ldaa TFLG1 ;10ms for bouncinganda #$08 ;OC5F set?beq loopRrts5Slide 11'&$%Software DebouncingSlide 12'&$%Software Debouncing with Gadfly Synchronization* Reg B is the return valueReadPA0: ldd TCNTaddd #20000 ;10ms delaystd TOC5ldaa #$08staa TFLG1 ;clear OC5Fldab PORTA ;0 if pressedandb #$01 ;B=old valueSame: ldaa TFLG1 ;10ms bouncinganda #$08 ;OC5F set?bne Doneldaa PORTA ;0 if pressedanda #$01 ;A=new valuecba ;same as beforebeq Samebra ReadPA0 ;different, start overDone: rts6Slide 13'&$%Basic Approaches to Interfacing Multiple KeysRow Out3 Out2 Out1 Out03 0 HiZ HiZ HiZ2 HiZ 0 HiZ HiZ1 HiZ HiZ 0 HiZ0 HiZ HiZ HiZ 0Row Out3 Out2 Out1 Out0 15 14 . . . 015 1 1 1 1 0 HiZ . . . HiZ14 1 1 1 0 HiZ 0 . . . HiZ. . . . . . . . . . . . . . . . . . . . . . . . . . .0 0 0 0 0 HiZ HiZ . . . 0Slide 14'&$%4 by 4 Scanned KeyboardRow 3 Row 2 Row 1 Row 0 Col 3 Col 2 Col 1 Col 00 1 1 1 a b c d1 0 1 1 e f g h1 1 0 1 i j k l1 1 1 1 m n o p7Slide 15'&$%4 by 4 Scanned Keyboard• There are two steps to scan a particular row:1. Select that row by driving low while other rows arenot driven.2. Read the columns to see if any keys are pressed inthat row (0 means key pressed, 1 means not pressed).• The scanned keyboard operates properly if:1. No key is pressed.2. Exactly one key is pressed.3. Exactly two keys are pressed.Slide 16'&$%Software for Matrix Scanned KeyboardRitual: ldaa #$20staa PIOC ;CWOM=1ldaa #$F0 ;PC7-PC4 outputsstaa DDRC ;PC3-PC0 inputsrtsScanTab: fcb %01110000 ;PC7 rowfcc "abcd" ;charactersfcb %10110000 ;PC6 rowfcc "efgh" ;charactersfcb %11010000 ;PC5 rowfcc "ijkl" ;charactersfcb %11100000 ;PC4 rowfcc "mnop" ;charactersfcb 08Slide 17'&$%Software for Matrix Scanned Keyboard; Returns RegA ASCII key pressed,; RegY number of keys pressed; Y=0 if no key pressedScan: ldy #0 ;Number pressedldx #ScanTabLoop: ldab 0,xbeq Donestab PORTC ;select rowldab PORTC ;read columnslsrb ;PC0 into carrybcs NotPC0ldaa 4,xinySlide 18'&$%Software for Matrix Scanned KeyboardNotPC0: lsrb ;PC1 into carrybcs NotPC1ldaa 3,xinyNotPC1: lsrb ;PC2 into carrybcs NotPC2ldaa 2,xinyNotPC2: lsrb ;PC3 into carrybcs NotPC3ldaa 1,xinyNotPC3: ldab #5 ;Size of entryabxbra LoopDone:


View Full Document

U of U ECE 3720 - LECTURE NOTES

Course: Ece 3720-
Pages: 5
Download LECTURE NOTES
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view LECTURE NOTES and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view LECTURE NOTES 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?