51单片机驱动模数转换器ads774数据采集汇编程序,脉冲6061五个,BCD码78~7B,段码70~73,TIM0用7FH,看门狗P3.3 。 ORG 0 LJMP MAIN ORG 000BH TM1:LJMP TIM0 ORG 0100H MAIN:MOV SP,#30H MOV R0,#20H;20--7F=0 CLR A MOV R7,#60H INB1:MOV @R0,A INC R0 DJNZ R7,INB1 MOV IP,#02H MOV 7FH,#7 MOV TMOD,#11H MOV TL0,#0AEH MOV TH0,#74H SETB TR0 SETB ET0 CLR P3.3 ;WATCH DOG CLOCK NOP SETB P3.3 SETB EA CA0:MOV DPTR,#7FFFH MOV A,#0D1H MOVX @DPTR,A IN1:MOVX A,@DPTR JB ACC.7,IN1 MOV A,#30H MOVX @DPTR,A MOV A,#08H MOVX @DPTR,A ED: lcall abcd CLR P3.3 ;WATCH DOG CLOCK NOP SETB P3.3 SJMP ED DSY2:NOP;BCD码78~7B转为段码送入70~73 MOV R7,#04H MOV R1,#70H MOV R0,#78H DIS2: MOV A,@R0 MOV DPTR,#DDDA MOVC A,@A+DPTR MOV @R1,A INC R0 INC R1 DJNZ R7,DIS2 DDD8:NOP RET DSY3:MOV DPTR,#7FFFH MOV A,#90H MOVX @DPTR,A MOV R7,#04H ;段码送显示,共4位 MOV R0,#70H TM00: MOV A,@R0 MOV DPTR,#7FFEH MOVX @DPTR,A INC R0 DJNZ R7,TM00 CLR A MOVX @DPTR,A MOVX @DPTR,A MOVX @DPTR,A MOVX @DPTR,A RET DDDA:DB 3FH,06H,5BH DB 4FH,66H,6DH DB 7DH,07H,7FH DB 6FH,77H,7CH DB 39H,5EH,79H DB 71H,7CH,39H DB 5EH,3EH,6EH DB 40H,0FFH,0BFH DB 76H,00H,00H DB 00H,00H,00H BICD:CLR A MOV 61H,A MOV 62H,A MOV R1,#10H CLR C BIC1:MOV A,@R0 RLC A MOV @R0,A MOV A,61H ADDC A,61H DA A MOV 61H,A MOV A,60H ADDC A,60H DA A MOV 60H,A DJNZ R1,BIC1 BBBB:RET AD:MOV A,B MOV R0,#60H MOV R7,#5;5次A/D ADD1:MOV A,#7 LCALL AO00 ADD3:MOV A,R2 MOV @R0,A INC R0 MOV A,R3 MOV @R0,A INC R0 DJNZ R7,ADD1 MOV R0,#64H;6465拆分送入78--7BH MOV R1,#78H; Z6:MOV A,@R0 MOV B,A ANL A,#0F0H SWAP A MOV @R1,A MOV A,B ANL A,#0FH INC R1 MOV @R1,A INC R0 MOV A,@R0 MOV B,A ANL A,#0F0H SWAP A INC R1 MOV @R1,A MOV A,B ANL A,#0FH INC R1 MOV @R1,A RET TIM0:NOP CLR TR0 MOV TH0,#74H MOV TL0,#0AEH SETB TR0 PUSH DPL PUSH DPH PUSH B PUSH PSW PUSH ACC SETB PSW.4 DEC 7FH MOV A,7FH CJNE A,#00H,TTT MOV 7FH,#7 LCALL AD LCALL DSY2 LCALL DSY3 TTT:POP ACC POP PSW POP B POP DPH POP DPL RETI AO0:MOV A,#0 AO00: MOV DPTR,#0BFFFH MOVX @DPTR,A;通道@ACC LCALL ABCD CLR P1.5;A0/SC=P1.5=0,R/C=P1.6=0启动 CLR P1.6 LCALL ABCD MOVX @DPTR,A LCALL ABCD SETB P1.6 ;停止启动 LCALL ABCD MOVX A,@DPTR;R/C=RD^A574=1,平时=0 MOV R2,A;高8位A0/SC=P1.5=0,R/C=1 SETB P1.5 LCALL ABCD MOVX A,@DPTR MOV R3,A;低4位A0/SC=P1.5=1 LCALL AD1 RET ABCD:MOV R5,#40H ABC1:DJNZ R5,ABC1 RET AD1:MOV A,R2;R2R3右移一字节 MOV B,A ANL A,#0F0H SWAP A MOV R2,A MOV A,B ANL A,#0FH SWAP A MOV R5,A MOV A,R3 ANL A,#0F0H SWAP A ADD A,R5 MOV R3,A RET