Keyboard scan

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Hi All,
What is common/best way to scan the keypad?
I have CPU board (Z180) and keypad (4x4).
First way:
start:                 ld a,(timerflag)
                         cp a,1                              ;Check for int
Timer 0
                         call z, keyscan                 ;Yes, check keypad
and save it
                         .....                      ;DO another things
                        jp start

;---------------Timer 0 ISR----------------------------------------
timer0isr:         push af
                        ld a,1
                        ld (timerflag),a                 ;set timer flag
                        in0 a,tcr
                        in0 a,tmdrl0
                        pop af
                        ei
                        reti

Second way:
start:                ld a,(keypadflag)
                        cp a, 1  ;check for any pressed key
                        jr z, DO MY THING
                        jp start
;---------------Timer 0 ISR----------------------------------------
timer0isr:        push af
                       call keyscan                      ;Scan keypad, save
result and set keypadflag
                       in0 a,tcr
                       in0 a,tmdrl0
                       pop af
                       ei
                       reti
In first example CALL KEYSCAN inserted in main program.
In second example CALL KEYSCAN inserted in TIMER 0 ISR routine.

Thank you,
Val



Site Timeline