TLC5620 DA轉換匯編程序
SPI_DATA BIT P1.1
SPI_CLK BIT P1.2
CS_DA BIT P1.3
ORG 0000H
AJMP START
ORG 0010H
TLC5620: ;;D/A轉換主程序
CLR A
SETB CS_DA
MOV R6,#43H ;;寫D/A命令字(通道數(shù)的選擇)
COMMAND: ADD A,ACC
MOV SPI_DATA,C
SETB SPI_CLK
NOP
NOP
NOP
NOP
CLR SPI_CLK
DJNZ R6,COMMAND
MOV A,R7
MOV R6,#08H
DATE : ADD A,ACC ;;寫D/A數(shù)據(jù)
MOV SPI_DATA,C
SETB SPI_CLK
NOP
NOP
NOP
NOP
CLR SPI_CLK
DJNZ R6,DATE
CLR CS_DA
NOP
NOP
SETB CS_DA
RET
DEL: ;;延時程序
MOV R1,#01H
DEL0:
MOV R2,#60H
DEL1:
MOV R3,#0FFH
DJNZ R3,$
DJNZ R2,DEL1
DJNZ R1,DEL0
RET
START:
MOV R7,#0FFH ;;數(shù)據(jù)減一處理程序,并進行轉換(FF--80)
LOOP1:
ACALL TLC5620
ACALL DEL
DEC R7
CJNE R7,#80H,LOOP1
MOV R7,#80H ;;數(shù)據(jù)加一處理程序,并進行轉換(80--FF)
LOOP2:
ACALL TLC5620
ACALL DEL
INC R7
CJNE R7,#0FFH,LOOP2
AJMP START
END