Keyboard scan

Nov 29, 2003 0 Replies

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


Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required