English
Language : 

PD17012_15 Datasheet, PDF (248/320 Pages) Renesas Technology Corp – 4-BIT SINGLE-CHIP MICROCONTROLLERS WITH DIGITAL TUNING SYSTEM HARDWARE
µPD17012, 17P012
20.6.3 Inputting momentary switch by binary search
The key source controller/decoder requires 4 ms to input the key of one key source signal line.
To input the keys of 16 key source signals, therefore, it takes 64 ms.
It is therefore convenient if the binary search method explained in (1) and (2) below is used.
(1) Flowchart
When KS7 to KS0 are used as key source signals of momentary switch
START
Initialization
RA 0000B
AR KSDATA+RA
DBF @AR
KSR DBF
N
KEYJ = 1?
Y
RB P0D port register
Y
RA = RB = 0?
N
Y
RA > 7?
N
RA RA+RA
N
RB = 0?
Y
RA RA+1
; Sets key source controller
; Sets offset address of table storing key source data to RA
; Outputs key source data at offset address specified by RA
; Waits until data is latched to key input latch (4 ms)
; Saves key input data to RB
; If key input data and RA are "0", inputs all keys again because no
; key is input
; If RA is greater than "7", input of one key source ends and waits for
; chattering
; If RA is less than "7", updates RA and continues binary search
Y
RB = 0?
N
Chattering wait
DBF KSR
KSR DBF
N
KEYJ = 1?
Y
RC P0D port register
Y
RC = 0?
N
Checking of key data
END
; If there is no key input data, checks all keys again
; Even if this chattering wait is missing, chattering occurs for 4 ms
; Inputs key input determined by binary search to RC again
; If RC = 0, occurrence of chattering is determined, and keys are input
; from beginning
; Stores key input data before chattering to RB, data after chattering
; to RC, and key source data to RA
246
Data Sheet U10101EJ4V0DS