基于CH372的單片機波形采集程序
;***********判斷輸入端***********
TIM:CJNER2,#0F1H,TI1
AJMPWTT
TI1:CJNER2,#0F2H,TI2
AJMPUTT
TI2:CJNER2,#0F0H,AML
;***********數(shù)據(jù)采集1紅外輸入************
CT:JNBGET,QH_1
JBP3.7,CT
SETBTR0
THO:JNBP3.7,$
CLRTR0
MOVA,TH0
MOVR1,TL0
MOVTL0,#01H
MOVTH0,#00H
SETBTR0
MOV@R0,A
INCR0
MOVA,R1
MOV@R0,A
JBP3.7,$
CLRTR0
MOVA,TH0
MOVR1,TL0
MOVTL0,#01H
MOVTH0,#00H
SETBTR0
INCR0
MOV@R0,A
INCR0
MOVA,R1
MOV@R0,A
INCR0
DJNZR7,THO
CLRTR0
AJMPFZCX
QH_1:AJMPJSCS
;***********數(shù)據(jù)采集2無線輸入************
WTT:JNBGET,QH_2
JBP3.6,WTT
SETBTR0
THA:JNBP3.6,$
CLRTR0
MOVA,TH0
MOVR1,TL0
MOVTL0,#01H
MOVTH0,#00H
SETBTR0
MOV@R0,A
INCR0
MOVA,R1
MOV@R0,A
JBP3.6,$
CLRTR0
MOVA,TH0
MOVR1,TL0
MOVTL0,#01H
MOVTH0,#00H
SETBTR0
INCR0
MOV@R0,A
INCR0
MOVA,R1
MOV@R0,A
INCR0
DJNZR7,THA
CLRTR0
AJMPFZCX
QH_2:AJMPJSCS
;************數(shù)據(jù)采集3外部輸入************
UTT:JNBGET,QH_2
JBP3.5,UTT
SETBTR0
THB:JNBP3.5,$
CLRTR0
MOVA,TH0
MOVR1,TL0
MOVTL0,#01H
MOVTH0,#00H
SETBTR0
MOV@R0,A
INCR0
MOVA,R1
MOV@R0,A
JBP3.5,$
CLRTR0
MOVA,TH0
MOVR1,TL0
MOVTL0,#01H
MOVTH0,#00H
SETBTR0
INCR0
MOV@R0,A
INCR0
MOVA,R1
MOV@R0,A
INCR0
DJNZR7,THB
CLRTR0
;*************數(shù)據(jù)發(fā)送***********
FZCX:MOVR7,#122
MOVR0,#08H
ZDDS:MOVA,#2AH;CH372中斷命令通知PC機
ACALLXML
NOP
NOP
MOVA,#02H;可輸入8個字節(jié)
ACALLXSJ
MOVA,@R0;送入要上傳的數(shù)據(jù)
ACALLXSJ
INCR0
MOVA,@R0;送入要上傳的數(shù)據(jù)
ACALLXSJ
INCR0
ACALLFYL
MOVA,#22H;接受中斷數(shù)據(jù)
ACALLXML
ACALLDSJ
ACALLFYL
ACALLINO
DJNZR7,ZDDS
MOVR0,#08H
MOVR7,#61
AJMPJSCS
;********CH372讀出數(shù)據(jù)**********
OUT2:MOVA,#28H;讀端口2的命令
ACALLXML
ACALLDSJ
NOP
ACALLDSJ
NOP
RET
;****************
OUT1:NOP
PEND:NOP
LEEP:NOP
AJMPAMIT
;******釋放緩沖區(qū)子程序*****
INO:MOVA,#2BH;釋放當(dāng)前USB緩沖區(qū)
ACALLXML
NOP
NOP
RET
;*******寫入數(shù)據(jù)子程序*******
XSJ:CLRA0;寫入數(shù)據(jù)
NOP
NOP;延時2US,根據(jù)主頻來確定NOP的值
MOVP2,A
NOP
NOP;50NS就可以
SETBDX
NOP
NOP;延時1.2US根據(jù)主頻調(diào)整
RET
;*********延時子程序******
DYL:MOVR6,#100
D1:MOVR5,#50
DJNZR5,$
DJNZR6,D1
RET
FYL:MOVR6,#2
FD1:MOVR5,#68
DJNZR5,$
DJNZR6,FD1
RET
END本文引用地址:http://butianyuan.cn/article/201611/323821.htm
評論