;TLC549串行A/D转换器实验
;PIN1:REF+; PIN2:INPUT; PIN3:REF-; PIN4:GND
;;PIN5:CS; PIN6:DATAOUT; PIN7:CLOCK; PIN8:+5V
CS BIT P2.0
CLOCK BIT P2.1
DATE BIT P2.2
MEM EQU 70H
HH EQU 71H
MM EQU 72H
LL EQU 73H
ORG 0000H
AJMP STAR
ORG 0030H
TBB:DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H
DB 90H,88H,83H,0C6H,0A1H,86H,8EH
ORG 0050H
STAR:
SETB CS ;CS
CLR CLOCK ;CLOCK
MOV R5,#00H
;##########################模数转换
CLR CS
NOP
NXT: SETB CLOCK
NOP
MOV C,DATE
RRC A
CLR CLOCK
INC R5
CJNE R5,#8,NXT
MOV R5,#00H
SETB CS
MOV MEM,A ;转换结果放于MEM
;######################16进制码转换成BCD码
MOV B,#100
DIV AB
MOV HH,A
MOV A,B
MOV B,#10
DIV AB
MOV MM,A
MOV LL,B
;######################显示结果
MOV R2,#100
ZH: MOV A,HH
MOV DPTR,#TBB
MOVC A,@A+DPTR
MOV P0,A
MOV P1,#11111101B
ACALL D1MS
MOV A,MM
MOV DPTR,#TBB
MOVC A,@A+DPTR
MOV P0,A
MOV P1,#11111011B
ACALL D1MS
MOV A,LL
MOV DPTR,#TBB
MOVC A,@A+DPTR
MOV P0,A
MOV P1,#11110111B
ACALL D1MS
DJNZ R2,ZH
AJMP STAR
;############################################
D1MS: MOV R7,#0AH
LOOP1: MOV R6,#32H
LOOP2: DJNZ R6,LOOP2
DJNZ R7,LOOP1
RET
END
上一篇:ATMega8 中断方式UART测试程序
下一篇:AT90S8515与点阵液晶模块的C语言编程实例源程序
推荐阅读最新更新时间:2024-03-16 15:49