?? icex56.dt
字號:
mov a, @0xef
iow P6CR
bs port6, 4
call delay
jbc port5, 0
bs port64, output1
nop
bc port6, 4
call delay
jbs port5, 0
bs port64, output0
/**************************************/
port65_check:
mov a, @0x0f ;set P65 output,others input
iow P5CR
mov a, @0xdf
iow P6CR
bs port6, 5
call delay
jbc port5, 0
bs port65, output1
nop
bc port6, 5
call delay
jbs port5, 0
bs port65, output0
/**************************************/
port66_check:
mov a, @0x0f ;set P66 output,others input
iow P5CR
mov a, @0xbf
iow P6CR
bs port6, 6
call delay
jbc port5, 0
bs port66, output1
nop
bc port6, 6
call delay
jbs port5, 0
bs port66, output0
/**************************************/
port67_check:
mov a, @0x0f ;set P67 output,others input
iow P5CR
mov a, @0x7f
iow P6CR
bs port6, 7
call delay
jbc port5, 0
bs port67, output1
nop
bc port6, 7
call delay
jbs port5, 0
bs port67, output0
/**************************************/
pull_down_check:
nop
nop
p67pull_high:
mov a, @0xff
iow PDCR
mov a, @0x7f
iow PHCR
mov a, @0x0f
iow P5CR
mov a, @0xff
iow P6CR
call delay
jbc port6, 7
bs pullhigh_buf,p67_high
nop
/**************************************/
p50pull_down:
mov a, @0xff
iow PHCR
mov a, @0xfe
iow PDCR
mov a, @0x0f
iow P5CR
mov a, @0xff
iow P6CR
call delay
jbs port5, 0
bs pulldown_buf,p50_down
nop
/**************************************/
p66pull_high:
mov a, @0xff
iow PDCR
mov a, @0xbf
iow PHCR
mov a, @0x0f
iow P5CR
mov a, @0xff
iow P6CR
call delay
jbc port6, 6
bs pullhigh_buf,p66_high
nop
/**************************************/
p51pull_down:
mov a, @0xff
iow PHCR
mov a, @0xfd
iow PDCR
mov a, @0x0f
iow P5CR
mov a, @0xff
iow P6CR
call delay
jbs port5, 1
bs pulldown_buf,p51_down
nop
/**************************************/
p65pull_high:
mov a, @0xff
iow PDCR
mov a, @0xdf
iow PHCR
mov a, @0x0f
iow P5CR
mov a, @0xff
iow P6CR
call delay
jbc port6, 5
bs pullhigh_buf,p65_high
nop
/**************************************/
p52pull_down:
mov a, @0xff
iow PHCR
mov a, @0xfb
iow PDCR
mov a, @0x0f
iow P5CR
mov a, @0xff
iow P6CR
call delay
jbs port5, 2
bs pulldown_buf,p52_down
nop
/**************************************/
p64pull_high:
mov a, @0xff
iow PDCR
mov a, @0xef
iow PHCR
mov a, @0x0f
iow P5CR
mov a, @0xff
iow P6CR
call delay
jbc port6, 4
bs pullhigh_buf,p64_high
nop
/**************************************/
p60pull_down:
mov a, @0xff
iow PHCR
mov a, @0xef
iow PDCR
mov a, @0x0f
iow P5CR
mov a, @0xff
iow P6CR
call delay
jbs port6, 0
bs pulldown_buf,p60_down
nop
/**************************************/
p60pull_high:
mov a, @0xff
iow PDCR
mov a, @0xfe
iow PHCR
mov a, @0x0f
iow P5CR
mov a, @0xff
iow P6CR
call delay
jbc port6, 0
bs pullhigh_buf,p60_high
nop
/**************************************/
p61pull_down:
mov a, @0xff
iow PHCR
mov a, @0xdf
iow PDCR
mov a, @0x0f
iow P5CR
mov a, @0xff
iow P6CR
call delay
jbs port6, 1
bs pulldown_buf,p61_down
nop
p61pull_high:
mov a, @0xff
iow PDCR
mov a, @0xfb
iow PHCR
mov a, @0x0f
iow P5CR
mov a, @0xff
iow P6CR
call delay
jbc port6, 1
bs pullhigh_buf,p61_high
nop
/**************************************/
p62pull_down:
mov a, @0xff
iow PHCR
mov a, @0xbf
iow PDCR
mov a, @0x0f
iow P5CR
mov a, @0xff
iow P6CR
call delay
jbs port6, 2
bs pulldown_buf,p62_down
nop
/**************************************/
p62pull_high:
mov a, @0xff
iow PDCR
mov a, @0xfb
iow PHCR
mov a, @0x0f
iow P5CR
mov a, @0xff
iow P6CR
call delay
jbc port6, 2
bs pullhigh_buf,p62_high
nop
/**************************************/
p63pull_down:
mov a, @0xff
iow PHCR
mov a, @0x7f
iow PDCR
mov a, @0x0f
iow P5CR
mov a, @0xff
iow P6CR
call delay
jbs port6, 3
bs pulldown_buf,p63_down
nop
/**************************************/
p63pull_high:
mov a, @0xff
iow PDCR
mov a, @0xf7
iow PHCR
mov a, @0x0f
iow P5CR
mov a, @0xff
iow P6CR
call delay
jbc port6, 3
bs pullhigh_buf,p63_high
nop
/**************************************/
tcc_check: mov a, @0xff ;set tcc interrupt
iow PDCR
iow PHCR
mov a, @0x0f
iow P5CR
mov a, @0xff
iow P6CR
mov a, @0x00
contw
clr RF
mov a, @0x37
mov TCC, a
mov a, @0x01
iow IOCF
eni
call delay
mov a, @0x00
iow IOCF
disi
/**************************************/
int0_check: mov a, @0x0e ;set P50 output,others input
iow P5CR
mov a, @0xff
iow P6CR
mov a, @0x40
iow WDTCR
clr RF
mov a, @0x04
iow IOCF
eni
bs port5, 0
call delay
bc port5, 0
call delay
mov a, @0x00
iow IOCF
disi
/**************************************/
port6_change:
mov a, @0x0f
iow P5CR
mov a, @0xff ;set port6 input
iow P6CR
mov a, @0xfe ;set port60 pull-high
iow PHCR
mov a, @0x06
contw
clr TCC
mov a, @0x0e
contw
wdtc
mov a, @0x00
iow WDTCR
nop
nop
mov port6, port6
nop
nop
eni
;disi
nop
nop
mov a, @0x02 ;enable port6 status change interrupt
iow IOCF
port6_change1:
nop
nop
slep
/**************************************/
nop
jbc flag, p60_flag
jmp port6_change2
call key_scan
jbs flag, key_over
jmp port6_change1
mov a, @0xff
mov port6_buf, a
;inc port6_buf
jmp wdt_check
port6_change2:
jbs flag, key_over
jmp port6_change1
;mov a, @0xff
;mov port6_buf, a
inc port6_buf
bc flag, p60_flag
/**************************************/
wdt_check: nop
inc wdt_buf
mov a, @0x8e
iow WDTCR
wdt_check1: nop
;wdtc
nop
nop
call delay
call delay
jmp wdt_check1
/**************************************/
intin: disi ;interrupt service routine
jbc RF, 0
jmp tcc_interrupt
jbc RF, 1
jmp port6_interrupt
jbc RF, 2
jmp int_interrupt
intin1: mov a, @0x00
mov RF, a
iow IOCF
reti
/**************************************/
tcc_interrupt:
mov temp_A, a
swap temp_A
swapa r3
mov temp_S, a ;tcc interrupt service routine
inc tcc_buf
mov a, @0x37
mov tcc, a
mov a, @0x01
iow IOCF
mov a, RF
and a, @0x06
mov RF, a
swapa temp_S
mov r3, a
swapa temp_A
reti
/**************************************/
port6_interrupt: ;port6 status change interrrupt service routine
mov temp_A, a
swap temp_A
swapa r3
mov temp_S, a
mov a, @0x00
iow WDTCR
call key_scan
bs flag, p60_flag
mov a, @0x02
or IOCF, a
mov a, RF
and a, @0x05
mov RF, a
swapa temp_S
mov r3, a
swapa temp_A
reti
/**************************************/
int_interrupt: ;int0 interrupt service routine
mov temp_A, a
swap temp_A
swapa r3
mov temp_S, a
inc int0_buf
mov a, @0x04
or IOCF, a
mov a, RF
and a, @0x03
mov RF, a
swapa temp_S
mov r3, a
swapa temp_A
reti
/**************************************/
key_scan:
jbs port6, 0
jmp key_close
key_open:
jbs flag, key_flag
jmp key_open1
bc flag, key_flag
jmp key_scan
key_open1:
jbc flag, key_state
jmp key_open2
bc flag, key_over
jmp key_off
key_open2:
bs flag, key_over
bc flag, key_state
jmp key_off
/**************************************/
key_close:
jbc flag, key_flag
jmp key_close1
call delay
call delay
call delay
bs flag, key_flag
jmp key_scan
key_close1:
jbc flag, key_state
jmp key_close2
call delay
bs flag, key_state
key_close2:
call delay
jmp key_scan
key_off: nop
ret
/**************************************/
delay: nop
mov a, @0x04 ;delay 2ms
mov dt1, a
delay1: nop
mov a, @0xfa
mov dt2, a
delay2: nop
nop
djz dt2
jmp delay2
djz dt1
jmp delay1
nop
ret
/**************************************/
IO_error: nop
nop
nop
mov a, @0xff
mov port50, a
IO_error1: nop
nop
jmp IO_error
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -