II-32
EPSON
S1C88348/317/316/308 TECHNICAL SOFTWARE
7 I/O PORTS (P PORTS)
Source List
(2) Scan for 2 x 2 switch matrix
;************************************************************************
;*
*
;*
p(i/o) port control (internal pull up delay)
*
;*
r51
r50(n-channel open drain)
*
;*
p11(pull up)
*
;*
p10(pull up)
*
;*
7
6
5
4
3
2
1
0
*
;*
switch data
0
0 r51/p11 r51/p10 r50/p11 r50/p10
*
;*
*
;************************************************************************
;*** initialize routine
init_switch:
ld
br,#br_io
;set br reg. address to 0ffxxh
ld
[br:low ioc1],#00000000b
;set ioc1 (p17-10=input)
or
[br:low hzr_ex],#11000000b
;r5x <- high impledance "hi-z"
and
[br:low r5d],#11111100b
;r5x <- "l"
ret
;************************************************************************
;*** control routine
io_switch:
ld
br,#br_io
;set br reg. address to 0ffxxh
xor
a,a
ld
b,#2
;switch scan loop counter
ld
hl,#lod switch_data
;switch data buffer
ld
[hl],#0
;clear switch data buffer
ld
a,#00100000b
;scan init. data set
switch00:
sll
a
;scan data move bit0 to 7
push
ba
;escape scan data
ld
b,[br:low hzr_ex]
;r5x hi-z control ("hi-z" <-> "l")
and
b,#00111111b
or
a,b
ld
[br:low hzr_ex],a
;r5x scan data control with hi-z
pop
ba
push
hl
carl
switch_delay
;switch scan delay ***
pop
hl
bit
[br:low p1d],#00000010b
;compare p11 port level
jrs
nz,switch01
;switch (p11) on "l"
and
sc,#11111101b
;clear carry flag
jrs
switch02
;switch (p11) off "h"
switch01:
or
sc,#00000010b
;set carry flag
switch02:
rl
[hl]
;set switch data buffer
bit
[br:low p1d],#00000001b
;compare p10 port level
jrs
nz,switch03
;switch (p10) on "l"
and
sc,#11111101b
;clear carry flag
jrs
switch04
;switch (p10) off "h"
switch03:
or
sc,#00000010b
;set carry flag
switch04:
rl
[hl]
;set switch data buffer
djr
nz,switch00
;
ret
;
end
(2)