; b: error code
|
; b: error code
|
; r3: timer high expected value
|
; r3: timer high expected value
|
; r4: timer low expected value
|
; r4: timer low expected value
|
|
|
|
|
t2con EQU 0c8h;
|
t2con EQU 0c8h;
|
rcap2l EQU 0cah;
|
rcap2l EQU 0cah;
|
rcap2h EQU 0cbh;
|
rcap2h EQU 0cbh;
|
tl2 EQU 0cch;
|
tl2 EQU 0cch;
|
th2 EQU 0cdh;
|
th2 EQU 0cdh;
|
|
|
tr2 EQU 0cah;
|
tr2 EQU 0cah;
|
exen2 EQU 0cbh;
|
exen2 EQU 0cbh;
|
exf2 EQU 0ceh;
|
exf2 EQU 0ceh;
|
tf2 EQU 0cfh;
|
tf2 EQU 0cfh;
|
|
|
ajmp start;
|
ajmp start;
|
|
|
org 03h ; external interrupt 0
|
org 03h ; external interrupt 0
|
reti;
|
reti;
|
|
|
org 0bh ; t/c 0 interrupt
|
org 0bh ; t/c 0 interrupt
|
reti;
|
reti;
|
|
|
org 13h ; external interrupt 1
|
org 13h ; external interrupt 1
|
reti;
|
reti;
|
|
|
org 1bh ; t/c 1 interrupt
|
org 1bh ; t/c 1 interrupt
|
reti;
|
reti;
|
|
|
org 23h ; serial interface interrupt
|
org 23h ; serial interface interrupt
|
reti;
|
reti;
|
|
|
org 2bh; t/c 2 interrupt
|
org 2bh; t/c 2 interrupt
|
reti;
|
reti;
|
|
|
|
|
test2:
|
test2:
|
mov a, th2 ;
|
mov a, th2 ;
|
subb a, r3 ;
|
subb a, r3 ;
|
jnz error ;
|
jnz error ;
|
|
|
mov a,tl2 ;
|
mov a,tl2 ;
|
subb a, r4 ;
|
subb a, r4 ;
|
jnz error ;
|
jnz error ;
|
|
|
ret;
|
ret;
|
|
|
|
|
error:
|
error:
|
mov p1, b;
|
mov p1, b;
|
nop;
|
nop;
|
ajmp error;
|
ajmp error;
|
|
|
|
|
wait:
|
wait:
|
dec a ; 1
|
dec a ; 1
|
nop ; 1
|
nop ; 1
|
nop ; 1
|
nop ; 1
|
nop ; 1
|
nop ; 1
|
nop ; 1
|
nop ; 1
|
nop ; 1
|
nop ; 1
|
nop ; 1
|
nop ; 1
|
nop ; 1
|
nop ; 1
|
jnz wait ; 4
|
jnz wait ; 4
|
nop;
|
nop;
|
; nop;
|
; nop;
|
nop;
|
nop;
|
ret ; 4
|
ret ; 4
|
|
|
|
|
|
|
start:
|
start:
|
clr a;
|
clr a;
|
mov r0, a;
|
mov r0, a;
|
mov r1, a;
|
mov r1, a;
|
mov ie, #00h ;disable interrupts
|
mov ie, #00h ;disable interrupts
|
clr c;
|
clr c;
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;
|
;
|
; timer 2 test
|
; timer 2 test
|
;
|
;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;
|
;
|
; capture mode
|
; capture mode
|
;
|
;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
mov tcon, #000h ; disable t/c 0,1
|
mov tcon, #000h ; disable t/c 0,1
|
mov t2con, #01h; timer 2 capture mode,
|
mov t2con, #01h; timer 2 capture mode,
|
mov th2, #000h ;load timer 2
|
mov th2, #000h ;load timer 2
|
mov tl2, #000h ;
|
mov tl2, #000h ;
|
setb tr2 ;start timer 2;
|
setb tr2 ;start timer 2;
|
mov a, #03h ; 1
|
mov a, #03h ; 1
|
acall wait ; 2
|
acall wait ; 2
|
|
|
clr tr2 ;stop timer 2
|
clr tr2 ;stop timer 2
|
mov b, #00h ; error 0
|
mov b, #00h ; error 0
|
mov r3, #000h ;
|
mov r3, #000h ;
|
mov r4, #004h ;
|
mov r4, #004h ;
|
acall test2 ;
|
acall test2 ;
|
|
|
mov tl2, #0fch ; load timer 2
|
mov tl2, #0fch ; load timer 2
|
setb tr2 ; start timer 2;
|
setb tr2 ; start timer 2;
|
mov a, #04h ;
|
mov a, #04h ;
|
acall wait ;
|
acall wait ;
|
|
|
clr tr2 ; stop timer 2
|
clr tr2 ; stop timer 2
|
mov b, #01h ; error 1
|
mov b, #01h ; error 1
|
mov r3, #001h ;
|
mov r3, #001h ;
|
mov r4, #001h ;
|
mov r4, #001h ;
|
acall test2 ;
|
acall test2 ;
|
|
|
mov tl2, #0fch ;
|
mov tl2, #0fch ;
|
mov th2, #0ffh ;
|
mov th2, #0ffh ;
|
setb tr2 ;start timer 2
|
setb tr2 ;start timer 2
|
mov a, #05h ;
|
mov a, #05h ;
|
acall wait ;
|
acall wait ;
|
|
|
clr tr2 ;stop timer 0
|
clr tr2 ;stop timer 0
|
mov b, #02h ; error 2
|
mov b, #02h ; error 2
|
mov r3, #000h ;
|
mov r3, #000h ;
|
mov r4, #002h ;
|
mov r4, #002h ;
|
acall test2 ;
|
acall test2 ;
|
mov b, #03h ; error 3
|
mov b, #03h ; error 3
|
jnb tf2, error ;
|
jnb tf2, error ;
|
clr tf2 ;
|
clr tf2 ;
|
|
|
mov p0, #01h;
|
mov p0, #01h;
|
;
|
;
|
; test exen2
|
; test exen2
|
;
|
;
|
mov rcap2l, #43h
|
mov rcap2l, #43h
|
mov rcap2h, #21h
|
mov rcap2h, #21h
|
mov th2, #23h ;
|
mov th2, #23h ;
|
mov tl2, #45h ;
|
mov tl2, #45h ;
|
clr p3.2 ;
|
clr p3.2 ;
|
setb p3.2 ;
|
setb p3.2 ;
|
mov a, #10h ;
|
mov a, #10h ;
|
loop1: nop ;
|
loop1: nop ;
|
dec a ;
|
dec a ;
|
jnz loop1 ;
|
jnz loop1 ;
|
mov a, rcap2l ;
|
mov a, rcap2l ;
|
mov psw, #00h ;
|
mov psw, #00h ;
|
mov b, #04h ;error 4
|
mov b, #04h ;error 4
|
subb a, #43h ;
|
subb a, #43h ;
|
jnz error0 ;
|
jnz error0 ;
|
mov a, rcap2h ;
|
mov a, rcap2h ;
|
subb a, #21h ;
|
subb a, #21h ;
|
jnz error0 ;
|
jnz error0 ;
|
|
|
mov b, #05h ;error 5
|
mov b, #05h ;error 5
|
jb exf2, error0 ;
|
jb exf2, error0 ;
|
clr exf2 ;
|
clr exf2 ;
|
|
|
setb exen2 ;
|
setb exen2 ;
|
clr p3.2 ;
|
clr p3.2 ;
|
setb p3.2 ;
|
setb p3.2 ;
|
mov a, #10h ;
|
mov a, #10h ;
|
loop2: nop ;
|
loop2: nop ;
|
dec a ;
|
dec a ;
|
jnz loop2 ;
|
jnz loop2 ;
|
mov a, rcap2l ;
|
mov a, rcap2l ;
|
mov psw, #00h ;
|
mov psw, #00h ;
|
mov b, #06h ;error 6
|
mov b, #06h ;error 6
|
subb a, #45h ;
|
subb a, #45h ;
|
jnz error0 ;
|
jnz error0 ;
|
mov a, rcap2h ;
|
mov a, rcap2h ;
|
subb a, #23h ;
|
subb a, #23h ;
|
jnz error0 ;
|
jnz error0 ;
|
|
|
mov b, #07h ;error 7
|
mov b, #07h ;error 7
|
jnb exf2, error0;
|
jnb exf2, error0;
|
clr exf2 ;
|
clr exf2 ;
|
|
|
mov p0, #02h;
|
mov p0, #02h;
|
|
|
ajmp arm;
|
ajmp arm;
|
|
|
error0:
|
error0:
|
ljmp error;
|
ljmp error;
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;
|
;
|
; auto reload mode
|
; auto reload mode
|
;
|
;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
arm:
|
arm:
|
mov t2con, #00h ; t/c 2 in auto reload mode
|
mov t2con, #00h ; t/c 2 in auto reload mode
|
mov th2, #000h ;load timer 2
|
mov th2, #000h ;load timer 2
|
mov tl2, #000h ;
|
mov tl2, #000h ;
|
mov rcap2l, #11h;
|
mov rcap2l, #11h;
|
mov rcap2h, #22h;
|
mov rcap2h, #22h;
|
setb tr2 ;start timer 2;
|
setb tr2 ;start timer 2;
|
mov a, #03h ;
|
mov a, #03h ;
|
acall wait ;
|
acall wait ;
|
|
|
clr tr2 ;stop timer 2
|
clr tr2 ;stop timer 2
|
mov b, #08h ; error 8
|
mov b, #08h ; error 8
|
mov r3, #000h ;
|
mov r3, #000h ;
|
mov r4, #004h ;
|
mov r4, #004h ;
|
acall test2 ;
|
acall test2 ;
|
|
|
mov tl2, #0fch ; load timer 2
|
mov tl2, #0fch ; load timer 2
|
setb tr2 ; start timer 2
|
setb tr2 ; start timer 2
|
mov a, #04h ;
|
mov a, #04h ;
|
acall wait ;
|
acall wait ;
|
|
|
clr tr2 ; stop timer 2
|
clr tr2 ; stop timer 2
|
mov b, #09h ; error 9
|
mov b, #09h ; error 9
|
mov r3, #001h ;
|
mov r3, #001h ;
|
mov r4, #001h ;
|
mov r4, #001h ;
|
acall test2 ;
|
acall test2 ;
|
|
|
mov b, #0ah ; error a
|
mov b, #0ah ; error a
|
jb tf2, error0 ;
|
jb tf2, error0 ;
|
clr tf2 ;
|
clr tf2 ;
|
|
|
|
|
mov tl2, #0fch ;
|
mov tl2, #0fch ;
|
mov th2, #0ffh ;
|
mov th2, #0ffh ;
|
setb tr2 ;start timer 2
|
setb tr2 ;start timer 2
|
mov a, #05h ;
|
mov a, #05h ;
|
acall wait ;
|
acall wait ;
|
|
|
clr tr2 ;stop timer 0
|
clr tr2 ;stop timer 0
|
mov b, #0bh ; error b
|
mov b, #0bh ; error b
|
mov r3, #022h ;
|
mov r3, #022h ;
|
mov r4, #013h ;
|
mov r4, #013h ;
|
acall test2 ;
|
acall test2 ;
|
|
|
mov b, #0ch ; error c
|
mov b, #0ch ; error c
|
jnb tf2, error0 ;
|
jnb tf2, error0 ;
|
clr tf2 ;
|
clr tf2 ;
|
|
|
|
|
mov a, rcap2l ;
|
mov a, rcap2l ;
|
mov psw, #00h ;
|
mov psw, #00h ;
|
mov b, #0f0h ;error f0
|
mov b, #0f0h ;error f0
|
subb a, #11h ;
|
subb a, #11h ;
|
jnz error1 ;
|
jnz error1 ;
|
mov a, rcap2h ;
|
mov a, rcap2h ;
|
subb a, #22h ;
|
subb a, #22h ;
|
jnz error0 ;
|
jnz error0 ;
|
|
|
mov p0, #03h;
|
mov p0, #03h;
|
|
|
|
|
;
|
;
|
; test exen2
|
; test exen2
|
;
|
;
|
mov rcap2l, #12h
|
mov rcap2l, #12h
|
mov rcap2h, #34h
|
mov rcap2h, #34h
|
mov tl2, #56h ;
|
mov tl2, #56h ;
|
mov th2, #78h ;
|
mov th2, #78h ;
|
clr p3.2 ;
|
clr p3.2 ;
|
setb p3.2 ;
|
setb p3.2 ;
|
mov a, #10h ;
|
mov a, #10h ;
|
loop3: nop ;
|
loop3: nop ;
|
dec a ;
|
dec a ;
|
jnz loop3 ;
|
jnz loop3 ;
|
|
|
mov b, #0dh ; error d
|
mov b, #0dh ; error d
|
mov r3, #078h ;
|
mov r3, #078h ;
|
mov r4, #056h ;
|
mov r4, #056h ;
|
acall test2 ;
|
acall test2 ;
|
|
|
mov b, #0eh ; error e
|
mov b, #0eh ; error e
|
jb exf2, error1 ;
|
jb exf2, error1 ;
|
clr exf2 ;
|
clr exf2 ;
|
|
|
setb exen2 ;
|
setb exen2 ;
|
clr p3.2 ;
|
clr p3.2 ;
|
setb p3.2 ;
|
setb p3.2 ;
|
mov a, #10h ;
|
mov a, #10h ;
|
loop4: nop ;
|
loop4: nop ;
|
dec a ;
|
dec a ;
|
jnz loop4 ;
|
jnz loop4 ;
|
|
|
mov b, #0fh ; error f
|
mov b, #0fh ; error f
|
mov r3, #034h ;
|
mov r3, #034h ;
|
mov r4, #012h ;
|
mov r4, #012h ;
|
acall test2 ;
|
acall test2 ;
|
|
|
mov b, #10h ;error 10
|
mov b, #10h ;error 10
|
jnb exf2, error1;
|
jnb exf2, error1;
|
clr exf2 ;
|
clr exf2 ;
|
|
|
mov a, rcap2l ;
|
mov a, rcap2l ;
|
mov psw, #00h ;
|
mov psw, #00h ;
|
mov b, #0f1h ;error f1
|
mov b, #0f1h ;error f1
|
subb a, #12h ;
|
subb a, #12h ;
|
jnz error1 ;
|
jnz error1 ;
|
mov a, rcap2h ;
|
mov a, rcap2h ;
|
subb a, #34h ;
|
subb a, #34h ;
|
jnz error1 ;
|
jnz error1 ;
|
|
|
mov p0, #04h ;
|
mov p0, #04h ;
|
|
|
ajmp brate;
|
ajmp brate;
|
|
|
|
|
error1:
|
error1:
|
ljmp error;
|
ljmp error;
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;
|
;
|
; baud rate generator
|
; baud rate generator
|
;
|
;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
brate:
|
brate:
|
mov t2con, #10h ; t/c 2 in baud rate generator mode
|
mov t2con, #10h ; t/c 2 in baud rate generator mode
|
mov th2, #000h ;load timer 2
|
mov th2, #000h ;load timer 2
|
mov tl2, #000h ;
|
mov tl2, #000h ;
|
mov rcap2l, #11h;
|
mov rcap2l, #11h;
|
mov rcap2h, #22h;
|
mov rcap2h, #22h;
|
setb tr2 ;start timer 2;
|
setb tr2 ;start timer 2;
|
mov a, #03h ;
|
mov a, #03h ;
|
acall wait ;
|
acall wait ;
|
|
|
clr tr2 ;stop timer 2
|
clr tr2 ;stop timer 2
|
mov b, #20h ; error 20
|
mov b, #20h ; error 20
|
mov r3, #000h ;
|
mov r3, #000h ;
|
mov r4, #004h ;
|
mov r4, #004h ;
|
acall test2 ;
|
acall test2 ;
|
|
|
mov t2con, #20h ;
|
mov t2con, #20h ;
|
mov tl2, #0fch ; load timer 2
|
mov tl2, #0fch ; load timer 2
|
setb tr2 ; start timer 2
|
setb tr2 ; start timer 2
|
mov a, #04h ;
|
mov a, #04h ;
|
acall wait ;
|
acall wait ;
|
|
|
clr tr2 ; stop timer 2
|
clr tr2 ; stop timer 2
|
mov b, #021h ; error 21
|
mov b, #021h ; error 21
|
mov r3, #001h ;
|
mov r3, #001h ;
|
mov r4, #001h ;
|
mov r4, #001h ;
|
acall test2 ;
|
acall test2 ;
|
|
|
mov b, #22h ; error 22
|
mov b, #22h ; error 22
|
jb tf2, error1 ;
|
jb tf2, error1 ;
|
clr tf2 ;
|
clr tf2 ;
|
|
|
|
|
mov tl2, #0fch ;
|
mov tl2, #0fch ;
|
mov th2, #0ffh ;
|
mov th2, #0ffh ;
|
setb tr2 ;start timer 2
|
setb tr2 ;start timer 2
|
mov a, #05h ;
|
mov a, #05h ;
|
acall wait ;
|
acall wait ;
|
|
|
clr tr2 ;stop timer 0
|
clr tr2 ;stop timer 0
|
mov b, #23h ; error 23
|
mov b, #23h ; error 23
|
mov r3, #022h ;
|
mov r3, #022h ;
|
mov r4, #013h ;
|
mov r4, #013h ;
|
acall test2 ;
|
acall test2 ;
|
|
|
mov b, #24h ; error 24
|
mov b, #24h ; error 24
|
jb tf2, error1 ;
|
jb tf2, error1 ;
|
clr tf2 ;
|
clr tf2 ;
|
|
|
|
|
mov a, rcap2l ;
|
mov a, rcap2l ;
|
mov psw, #00h ;
|
mov psw, #00h ;
|
mov b, #0f4h ;error f4
|
mov b, #0f4h ;error f4
|
subb a, #11h ;
|
subb a, #11h ;
|
jnz error1 ;
|
jnz error1 ;
|
mov a, rcap2h ;
|
mov a, rcap2h ;
|
subb a, #22h ;
|
subb a, #22h ;
|
jnz error1 ;
|
jnz error1 ;
|
|
|
mov p0, #07h;
|
mov p0, #07h;
|
|
|
|
|
;
|
;
|
; test exen2
|
; test exen2
|
;
|
;
|
mov tl2, #56h ;
|
mov tl2, #56h ;
|
mov th2, #78h ;
|
mov th2, #78h ;
|
setb p3.2 ;
|
setb p3.2 ;
|
clr p3.2 ;
|
clr p3.2 ;
|
setb p3.2 ;
|
setb p3.2 ;
|
mov a, #10h ;
|
mov a, #10h ;
|
loop5: nop ;
|
loop5: nop ;
|
dec a ;
|
dec a ;
|
jnz loop5 ;
|
jnz loop5 ;
|
|
|
mov b, #25h ; error 25
|
mov b, #25h ; error 25
|
mov r3, #078h ;
|
mov r3, #078h ;
|
mov r4, #056h ;
|
mov r4, #056h ;
|
acall test2 ;
|
acall test2 ;
|
|
|
mov b, #0eh ; error e
|
mov b, #0eh ; error e
|
jb exf2, error3 ;
|
jb exf2, error3 ;
|
clr exf2 ;
|
clr exf2 ;
|
|
|
setb exen2 ;
|
setb exen2 ;
|
clr p3.2 ;
|
clr p3.2 ;
|
setb p3.2 ;
|
setb p3.2 ;
|
mov a, #10h ;
|
mov a, #10h ;
|
loop6: nop ;
|
loop6: nop ;
|
dec a ;
|
dec a ;
|
jnz loop6 ;
|
jnz loop6 ;
|
|
|
mov b, #26h ; error 26
|
mov b, #26h ; error 26
|
mov r3, #078h ;
|
mov r3, #078h ;
|
mov r4, #056h ;
|
mov r4, #056h ;
|
acall test2 ;
|
acall test2 ;
|
|
|
mov b, #27h ;error 27
|
mov b, #27h ;error 27
|
jnb exf2, error3;
|
jnb exf2, error3;
|
clr exf2 ;
|
clr exf2 ;
|
|
|
|
|
mov p0, #08h ;
|
mov p0, #08h ;
|
ajmp counter;
|
ajmp counter;
|
|
|
error3:
|
error3:
|
ljmp error;
|
ljmp error;
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;
|
;
|
; counter 2 test
|
; counter 2 test
|
;
|
;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;
|
;
|
; capture mode
|
; capture mode
|
;
|
;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
counter:
|
counter:
|
mov tcon, #000h ; disable t/c 0,1
|
mov tcon, #000h ; disable t/c 0,1
|
mov t2con, #03h; timer 2 capture mode,
|
mov t2con, #03h; timer 2 capture mode,
|
mov th2, #000h ;load timer 2
|
mov th2, #000h ;load timer 2
|
mov tl2, #000h ;
|
mov tl2, #000h ;
|
setb tr2 ;start timer 2;
|
setb tr2 ;start timer 2;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
clr tr2 ;stop timer 2
|
clr tr2 ;stop timer 2
|
mov b, #00h ; error 0
|
mov b, #00h ; error 0
|
mov r3, #000h ;
|
mov r3, #000h ;
|
mov r4, #004h ;
|
mov r4, #004h ;
|
acall test2 ;
|
acall test2 ;
|
|
|
mov tl2, #0fch ; load timer 2
|
mov tl2, #0fch ; load timer 2
|
setb tr2 ; start timer 2;
|
setb tr2 ; start timer 2;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
clr tr2 ; stop timer 2
|
clr tr2 ; stop timer 2
|
mov b, #01h ; error 1
|
mov b, #01h ; error 1
|
mov r3, #001h ;
|
mov r3, #001h ;
|
mov r4, #001h ;
|
mov r4, #001h ;
|
acall test2 ;
|
acall test2 ;
|
|
|
mov tl2, #0fch ;
|
mov tl2, #0fch ;
|
mov th2, #0ffh ;
|
mov th2, #0ffh ;
|
setb tr2 ;start timer 2
|
setb tr2 ;start timer 2
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
clr tr2 ;stop timer 0
|
clr tr2 ;stop timer 0
|
mov b, #02h ; error 2
|
mov b, #02h ; error 2
|
mov r3, #000h ;
|
mov r3, #000h ;
|
mov r4, #002h ;
|
mov r4, #002h ;
|
acall test2 ;
|
acall test2 ;
|
mov b, #03h ; error 3
|
mov b, #03h ; error 3
|
jnb tf2, error4 ;
|
jnb tf2, error4 ;
|
clr tf2 ;
|
clr tf2 ;
|
|
|
mov p0, #09h;
|
mov p0, #09h;
|
;
|
;
|
; test exen2
|
; test exen2
|
;
|
;
|
mov rcap2l, #43h
|
mov rcap2l, #43h
|
mov rcap2h, #21h
|
mov rcap2h, #21h
|
mov th2, #23h ;
|
mov th2, #23h ;
|
mov tl2, #45h ;
|
mov tl2, #45h ;
|
clr p3.2 ;
|
clr p3.2 ;
|
setb p3.2 ;
|
setb p3.2 ;
|
mov a, #10h ;
|
mov a, #10h ;
|
loop7: nop ;
|
loop7: nop ;
|
dec a ;
|
dec a ;
|
jnz loop7 ;
|
jnz loop7 ;
|
mov a, rcap2l ;
|
mov a, rcap2l ;
|
mov psw, #00h ;
|
mov psw, #00h ;
|
mov b, #04h ;error 4
|
mov b, #04h ;error 4
|
subb a, #43h ;
|
subb a, #43h ;
|
jnz error4 ;
|
jnz error4 ;
|
mov a, rcap2h ;
|
mov a, rcap2h ;
|
subb a, #21h ;
|
subb a, #21h ;
|
jnz error4 ;
|
jnz error4 ;
|
|
|
mov b, #05h ;error 5
|
mov b, #05h ;error 5
|
jb exf2, error4 ;
|
jb exf2, error4 ;
|
clr exf2 ;
|
clr exf2 ;
|
|
|
setb exen2 ;
|
setb exen2 ;
|
clr p3.2 ;
|
clr p3.2 ;
|
setb p3.2 ;
|
setb p3.2 ;
|
mov a, #10h ;
|
mov a, #10h ;
|
loop8: nop ;
|
loop8: nop ;
|
dec a ;
|
dec a ;
|
jnz loop8 ;
|
jnz loop8 ;
|
mov a, rcap2l ;
|
mov a, rcap2l ;
|
mov psw, #00h ;
|
mov psw, #00h ;
|
mov b, #06h ;error 6
|
mov b, #06h ;error 6
|
subb a, #45h ;
|
subb a, #45h ;
|
jnz error4 ;
|
jnz error4 ;
|
mov a, rcap2h ;
|
mov a, rcap2h ;
|
subb a, #23h ;
|
subb a, #23h ;
|
jnz error4 ;
|
jnz error4 ;
|
|
|
mov b, #07h ;error 7
|
mov b, #07h ;error 7
|
jnb exf2, error4;
|
jnb exf2, error4;
|
clr exf2 ;
|
clr exf2 ;
|
|
|
mov p0, #0ah;
|
mov p0, #0ah;
|
|
|
ajmp armc;
|
ajmp armc;
|
|
|
error4:
|
error4:
|
ljmp error;
|
ljmp error;
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;
|
;
|
; auto reload mode
|
; auto reload mode
|
;
|
;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
armc:
|
armc:
|
mov t2con, #02h ; t/c 2 in auto reload mode
|
mov t2con, #02h ; t/c 2 in auto reload mode
|
mov th2, #000h ;load timer 2
|
mov th2, #000h ;load timer 2
|
mov tl2, #000h ;
|
mov tl2, #000h ;
|
mov rcap2l, #11h;
|
mov rcap2l, #11h;
|
mov rcap2h, #22h;
|
mov rcap2h, #22h;
|
setb tr2 ;start timer 2;
|
setb tr2 ;start timer 2;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
clr tr2 ;stop timer 2
|
clr tr2 ;stop timer 2
|
mov b, #08h ; error 8
|
mov b, #08h ; error 8
|
mov r3, #000h ;
|
mov r3, #000h ;
|
mov r4, #004h ;
|
mov r4, #004h ;
|
acall test2 ;
|
acall test2 ;
|
|
|
mov tl2, #0fch ; load timer 2
|
mov tl2, #0fch ; load timer 2
|
setb tr2 ; start timer 2
|
setb tr2 ; start timer 2
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
clr tr2 ; stop timer 2
|
clr tr2 ; stop timer 2
|
mov b, #09h ; error 9
|
mov b, #09h ; error 9
|
mov r3, #001h ;
|
mov r3, #001h ;
|
mov r4, #001h ;
|
mov r4, #001h ;
|
acall test2 ;
|
acall test2 ;
|
|
|
mov b, #0ah ; error a
|
mov b, #0ah ; error a
|
jb tf2, error4 ;
|
jb tf2, error4 ;
|
clr tf2 ;
|
clr tf2 ;
|
|
|
|
|
mov tl2, #0fch ;
|
mov tl2, #0fch ;
|
mov th2, #0ffh ;
|
mov th2, #0ffh ;
|
setb tr2 ;start timer 2
|
setb tr2 ;start timer 2
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
clr tr2 ;stop timer 0
|
clr tr2 ;stop timer 0
|
mov b, #0bh ; error b
|
mov b, #0bh ; error b
|
mov r3, #022h ;
|
mov r3, #022h ;
|
mov r4, #013h ;
|
mov r4, #013h ;
|
acall test2 ;
|
acall test2 ;
|
|
|
mov b, #0ch ; error c
|
mov b, #0ch ; error c
|
jnb tf2, error5 ;
|
jnb tf2, error5 ;
|
clr tf2 ;
|
clr tf2 ;
|
|
|
|
|
mov a, rcap2l ;
|
mov a, rcap2l ;
|
mov psw, #00h ;
|
mov psw, #00h ;
|
mov b, #0f0h ;error f0
|
mov b, #0f0h ;error f0
|
subb a, #11h ;
|
subb a, #11h ;
|
jnz error5 ;
|
jnz error5 ;
|
mov a, rcap2h ;
|
mov a, rcap2h ;
|
subb a, #22h ;
|
subb a, #22h ;
|
jnz error5 ;
|
jnz error5 ;
|
|
|
mov p0, #0bh;
|
mov p0, #0bh;
|
|
|
|
|
;
|
;
|
; test exen2
|
; test exen2
|
;
|
;
|
mov rcap2l, #12h
|
mov rcap2l, #12h
|
mov rcap2h, #34h
|
mov rcap2h, #34h
|
mov tl2, #56h ;
|
mov tl2, #56h ;
|
mov th2, #78h ;
|
mov th2, #78h ;
|
clr p3.2 ;
|
clr p3.2 ;
|
setb p3.2 ;
|
setb p3.2 ;
|
mov a, #10h ;
|
mov a, #10h ;
|
loop9: nop ;
|
loop9: nop ;
|
dec a ;
|
dec a ;
|
jnz loop9 ;
|
jnz loop9 ;
|
|
|
mov b, #0dh ; error d
|
mov b, #0dh ; error d
|
mov r3, #078h ;
|
mov r3, #078h ;
|
mov r4, #056h ;
|
mov r4, #056h ;
|
acall test2 ;
|
acall test2 ;
|
|
|
mov b, #0eh ; error e
|
mov b, #0eh ; error e
|
jb exf2, error5 ;
|
jb exf2, error5 ;
|
clr exf2 ;
|
clr exf2 ;
|
|
|
setb exen2 ;
|
setb exen2 ;
|
clr p3.2 ;
|
clr p3.2 ;
|
setb p3.2 ;
|
setb p3.2 ;
|
mov a, #10h ;
|
mov a, #10h ;
|
loop10: nop ;
|
loop10: nop ;
|
dec a ;
|
dec a ;
|
jnz loop10 ;
|
jnz loop10 ;
|
|
|
mov b, #0fh ; error f
|
mov b, #0fh ; error f
|
mov r3, #034h ;
|
mov r3, #034h ;
|
mov r4, #012h ;
|
mov r4, #012h ;
|
acall test2 ;
|
acall test2 ;
|
|
|
mov b, #10h ;error 10
|
mov b, #10h ;error 10
|
jnb exf2, error5;
|
jnb exf2, error5;
|
clr exf2 ;
|
clr exf2 ;
|
|
|
mov a, rcap2l ;
|
mov a, rcap2l ;
|
mov psw, #00h ;
|
mov psw, #00h ;
|
mov b, #0f1h ;error f1
|
mov b, #0f1h ;error f1
|
subb a, #12h ;
|
subb a, #12h ;
|
jnz error5 ;
|
jnz error5 ;
|
mov a, rcap2h ;
|
mov a, rcap2h ;
|
subb a, #34h ;
|
subb a, #34h ;
|
jnz error5 ;
|
jnz error5 ;
|
|
|
mov p0, #0ch ;
|
mov p0, #0ch ;
|
|
|
ajmp bratec;
|
ajmp bratec;
|
|
|
|
|
error5:
|
error5:
|
ljmp error;
|
ljmp error;
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;
|
;
|
; baud rate generator
|
; baud rate generator
|
;
|
;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
bratec:
|
bratec:
|
mov t2con, #12h ; t/c 2 in baud rate generator mode
|
mov t2con, #12h ; t/c 2 in baud rate generator mode
|
mov th2, #000h ;load timer 2
|
mov th2, #000h ;load timer 2
|
mov tl2, #000h ;
|
mov tl2, #000h ;
|
mov rcap2l, #11h;
|
mov rcap2l, #11h;
|
mov rcap2h, #22h;
|
mov rcap2h, #22h;
|
setb tr2 ;start timer 2;
|
setb tr2 ;start timer 2;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
clr tr2 ;stop timer 2
|
clr tr2 ;stop timer 2
|
mov b, #20h ; error 20
|
mov b, #20h ; error 20
|
mov r3, #000h ;
|
mov r3, #000h ;
|
mov r4, #004h ;
|
mov r4, #004h ;
|
acall test2 ;
|
acall test2 ;
|
|
|
mov tl2, #0fch ; load timer 2
|
mov tl2, #0fch ; load timer 2
|
setb tr2 ; start timer 2
|
setb tr2 ; start timer 2
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
clr tr2 ; stop timer 2
|
clr tr2 ; stop timer 2
|
mov b, #021h ; error 21
|
mov b, #021h ; error 21
|
mov r3, #001h ;
|
mov r3, #001h ;
|
mov r4, #001h ;
|
mov r4, #001h ;
|
acall test2 ;
|
acall test2 ;
|
|
|
mov b, #22h ; error 22
|
mov b, #22h ; error 22
|
jb tf2, error5 ;
|
jb tf2, error5 ;
|
clr tf2 ;
|
clr tf2 ;
|
|
|
|
|
mov tl2, #0fch ;
|
mov tl2, #0fch ;
|
mov th2, #0ffh ;
|
mov th2, #0ffh ;
|
setb tr2 ;start timer 2
|
setb tr2 ;start timer 2
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
cpl p3.5;
|
clr tr2 ;stop timer 0
|
clr tr2 ;stop timer 0
|
mov b, #23h ; error 23
|
mov b, #23h ; error 23
|
mov r3, #022h ;
|
mov r3, #022h ;
|
mov r4, #012h ;
|
mov r4, #012h ;
|
lcall test2 ;
|
lcall test2 ;
|
|
|
mov b, #24h ; error 24
|
mov b, #24h ; error 24
|
jb tf2, error8 ;
|
jb tf2, error8 ;
|
clr tf2 ;
|
clr tf2 ;
|
|
|
|
|
mov a, rcap2l ;
|
mov a, rcap2l ;
|
mov psw, #00h ;
|
mov psw, #00h ;
|
mov b, #0f4h ;error f4
|
mov b, #0f4h ;error f4
|
subb a, #11h ;
|
subb a, #11h ;
|
jnz error8 ;
|
jnz error8 ;
|
mov a, rcap2h ;
|
mov a, rcap2h ;
|
subb a, #22h ;
|
subb a, #22h ;
|
jnz error8 ;
|
jnz error8 ;
|
|
|
mov p0, #0fh;
|
mov p0, #0fh;
|
|
|
|
|
;
|
;
|
; test exen2
|
; test exen2
|
;
|
;
|
mov tl2, #56h ;
|
mov tl2, #56h ;
|
mov th2, #78h ;
|
mov th2, #78h ;
|
setb p3.2 ;
|
setb p3.2 ;
|
clr p3.2 ;
|
clr p3.2 ;
|
setb p3.2 ;
|
setb p3.2 ;
|
mov a, #10h ;
|
mov a, #10h ;
|
loop11: nop ;
|
loop11: nop ;
|
dec a ;
|
dec a ;
|
jnz loop11 ;
|
jnz loop11 ;
|
|
|
mov b, #25h ; error 25
|
mov b, #25h ; error 25
|
mov r3, #078h ;
|
mov r3, #078h ;
|
mov r4, #056h ;
|
mov r4, #056h ;
|
lcall test2 ;
|
lcall test2 ;
|
|
|
mov b, #0eh ; error e
|
mov b, #0eh ; error e
|
jb exf2, error8 ;
|
jb exf2, error8 ;
|
clr exf2 ;
|
clr exf2 ;
|
|
|
setb exen2 ;
|
setb exen2 ;
|
clr p3.2 ;
|
clr p3.2 ;
|
setb p3.2 ;
|
setb p3.2 ;
|
mov a, #10h ;
|
mov a, #10h ;
|
loop12: nop ;
|
loop12: nop ;
|
dec a ;
|
dec a ;
|
jnz loop12 ;
|
jnz loop12 ;
|
|
|
mov b, #26h ; error 26
|
mov b, #26h ; error 26
|
mov r3, #078h ;
|
mov r3, #078h ;
|
mov r4, #056h ;
|
mov r4, #056h ;
|
lcall test2 ;
|
lcall test2 ;
|
|
|
mov b, #27h ;error 27
|
mov b, #27h ;error 27
|
jnb exf2, error8;
|
jnb exf2, error8;
|
clr exf2 ;
|
clr exf2 ;
|
|
|
mov p0, #10h ;
|
mov p0, #10h ;
|
|
|
ajmp finish ;
|
ajmp finish ;
|
|
|
error8:
|
error8:
|
ljmp error;
|
ljmp error;
|
|
|
|
|
|
|
|
|
finish:
|
finish:
|
nop;
|
nop;
|
nop;
|
nop;
|
ajmp finish;
|
ajmp finish;
|
|
|
|
|
|
|
end
|
end
|
|
|
|
|
|
|
|
|
|
|