==========AD转换==============
入口:A(瞎激存放通道选择值:1***0000)
出口:A(存放AD转换值)
ADC:MOV R7,#4
CLR AD_CS
ADC1: CLR CLK
RLC A
MOV SDI,C
SETB CLK
DJNZ R7,ADC1
SETB SDO
CLR CLK
SETB CLK
MOV R7,#08H
ADC2: CLR CLK
SETB CLK
MOV C,SDO
RLC A
DJNZ R7,ADC2
MOV R7,#08H
ADC3: CLR CLK
SETB CLK
DJNZ R7,ADC3
CLR CLK
SETB AD_CS
RET
END
==============================
DA转换部分:使用MCP41010
入口参数:(A)=Dn
DAC: MOV R6,A
MOV R7,#08H
CLR DA_CS
DAC1: MOV A,#11H
DAC2: CLR CLK
RLC A
MOV SDI,C
SETB CLK
DJNZ R7,DAC2
MOV R7,#08H
MOV A,R6
DAC3: CLR CLK
RLC A
MOV SDI,C
SETB CLK
DJNZ R7,DAC3
CLR CLK
SETB DA_CS
RET
END
MIAN: MOV R1,#10
MOV R2,#40H
MOV R0,#7CH
MOVX @R0,A
LOOP: NOP
LOOP1:御返 NOP
JB P3.2,LOOP1
MOVX A,@R0
MOV @ R2,镇或饥A
INC R2
MOV R0,#7DH
MOVX A,@R0
MOV @R2,A
INC R2
DJNZ R1,团源LOOP
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)