1 / 15

Keypad

Keypad. Lecture L4.6. Port Integration Module. Reference:. PIM_9C32 Block Guide V01.06. S12C32PIMV1.pdf. Axiom 4 x 4 Hex Keypad. Port P. PTP equ $258 ; Port P PTIP equ $259 ; Port P input DDRP equ $25A ; Direction

mason
Télécharger la présentation

Keypad

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Keypad Lecture L4.6

  2. Port Integration Module Reference: PIM_9C32 Block Guide V01.06 S12C32PIMV1.pdf

  3. Axiom 4 x 4 Hex Keypad

  4. Port P

  5. PTP equ $258 ; Port P PTIP equ $259 ; Port P input DDRP equ $25A ; Direction RDRP equ $25B ; portP reduced drive register PERP equ $25C ; portP pull device enable PPSP equ $25D ; portP pull polarity select PIEP equ $25E ; portP interrupt enable register PIFP equ $25F ; portP interrupt flag register

  6. Axiom 4 x 4 Hex Keypad

  7. ; keypad.asm ; AXIOM keypad org $800 outa equ $FF4F PTP equ $258 ; Port P DDRP equ $25A ; Direction PERP equ $25C ; portP pull device enable PPSP equ $25D ; portP pull polarity select

  8. keycodes db $14 ; 0 db $88 ; 1 db $84 ; 2 db $82 ; 3 db $48 ; 4 db $44 ; 5 db $42 ; 6 db $28 ; 7 db $24 ; 8 db $22 ; 9 db $81 ; A db $41 ; B db $21 ; C db $11 ; D db $18 ; E/* db $12 ; F/#

  9. ; Initialize KEYPAD ; Port P 0-3 must be input with pull downs ; 4-7 must be output initkey ldaa #$F0 ; set Port P direction staa DDRP ldaa #$0f staa PPSP ; set for pull downs ldaa #$0f staa PERP ; enable pull downs rts

  10. ; scan all keys ; B = key pressed ; if B = #$10, no key pressed keyscan clrb ; B = index ldx #keycodes ks1 ldaa b,x staa ptp ;write next code nop ;wait to settle down nop ldaa ptp ;read it back cmpa b,x ;if key pressed, beq ks2 ; B = key incb ;else, inx index cmpb #$10 ; and scan all keys bne ks1 ;if no key pressed ks2 rts ; B = #$10 keycodes db $14 ; 0 db $88 ; 1 db $84 ; 2 db $82 ; 3 db $48 ; 4 db $44 ; 5 db $42 ; 6 db $28 ; 7 db $24 ; 8 db $22 ; 9 db $81 ; A db $41 ; B db $21 ; C db $11 ; D db $18 ; E/* db $12 ; F/#

  11. ; wait to press a key ; B = key value keypad bsr keyscan ;scan keypad cmpb #$10 ;until key pressed beq keypad rts

  12. Debounce ; debounced key input getkey bsr keypad ;wait for key pshb ;save key value ldy #3 jsr ms_delay ;delay ~10 ms bsr keypad ;wait for key pula ;get 1st value sba ;if not same as 2nd bne getkey ;repeat rts ;B = key value

  13. ; wait to lift finger from key wait_keyup bsr keyscan ;scan keypad cmpb #$10 ;while key is pressed bne wait_keyup ldy #3 jsr ms_delay ;delay ~10 ms bsr keyscan ;scan keypad cmpb #$10 ;if key is pressed bne wait_keyup ;repeat rts #include ms_delay.asm #include hexasc.asm

  14. org $4000 main bsr initkey ;initialize keypad mn1 jsr getkey ;get key input tba ;A = key hex value jsr hexasc ;convert to ascii jsr outa ;display on screen jsr wait_keyup ;wait to lift finger bra mn1 ;get more keys

More Related