DEL: MOV R5,#02 ;为演示方便,人为插入的延时 DEL01: MOV R6,#200 DEL02: MOV R7,#200 DJNZ R7,$ DJNZ R6,DEL02 DJNZ R5,DEL01 RET
BIN_BCD: MOV B,#10 DIV AB RET ;---------------------(ds18b20) 访问子程序,时序参见TRANSDATA.PDF文件---------------------------- DS_hart_RST:CLR DS18B20 ;总线复位 MOV R6,#250 ;>DELAY 480US DJNZ R6,$ setb ds18B20 MOV R6,#40 ;>DELAY 60US DJNZ R6,$ mov c,dS18B20 MOV R6,#250 ;>DELAY 480US DJNZ R6,$ setb DS18B20 RET
DS_hart_RD_BYTE: ;读取一字节数据 MOV R5,#08H RD_HART_BYTE_LP: NOP NOP CLR DS18B20 NOP NOP SETB DS18B20 MOV R6,#06 DJNZ R6,$ ;<DELAY 15US MOV C,DS18B20 RRC A MOV R6,#40 ;>DELAY 60US DJNZ R6,$ DJNZ R5,RD_HART_BYTE_LP RET
DS_HART_WR_BYTE: ;写入一字节指令 MOV R5,#08H CLR C WR_HART_BYTE_LP: nop nop CLR DS18B20 NOP NOP RRC A MOV R6,#06 DJNZ R6,$ setb ds18B20 MOV DS18B20,C MOV R6,#40 ;>DELAY 60US DJNZ R6,$ SETB DS18B20 DJNZ R5,WR_HART_BYTE_LP RET |