void TMWDS1820(void) //写入温度限制指令
{
#pragma asm
MOV A,#04EH
MOV R2,#8
CLR C
WR13:
CLR P3_7
MOV R3,#6
DJNZ R3,$
RRC A
MOV P3_7,C
MOV R3,#23
DJNZ R3,$
SETB P3_7
NOP
DJNZ R2,WR13
SETB P3_7
#pragma endasm
}
void TMREDS1820(void) //COPY RAM to E2PRAM
{
#pragma asm
MOV A,#48H
MOV R2,#8
CLR C
WR33:
CLR P3_7
MOV R3,#6
DJNZ R3,$
RRC A
MOV P3_7,C
MOV R3,#23
DJNZ R3,$
SETB P3_7
NOP
DJNZ R2,WR33
SETB P3_7
#pragma endasm
}
void TMERDS1820(void) //COPY E2PRAM to RAM
{
#pragma asm
MOV A,#0B8H
MOV R2,#8
CLR C
WR43:
CLR P3_7
MOV R3,#6
DJNZ R3,$
RRC A
MOV P3_7,C
MOV R3,#23
DJNZ R3,$
SETB P3_7
NOP
DJNZ R2,WR43
SETB P3_7
#pragma endasm
}
void WriteDS1820(void) //写入温度限制值
{
#pragma asm
MOV A,26H //发出4EH写ROM指令后连发两个字节分别为上下限
MOV R2,#8
CLR C
WR23:
CLR P3_7
MOV R3,#6
DJNZ R3,$
RRC A
MOV P3_7,C
MOV R3,#23
DJNZ R3,$
SETB P3_7
NOP
DJNZ R2,WR23
SETB P3_7
#pragma endasm
}
void ReadDS1820(void) //读出温度值
{
#pragma asm
MOV R4,#3 ; 将温度高位和低位,高温限制位从DS18B20中读出
MOV R1,#29H ; 低位存入29H(TEMPER_L),高位存入28H(TEMPER_H),高温限制位存入27H(TMRomV)
RE00:
MOV R2,#8
RE01:
CLR C
SETB P3_7
NOP
NOP
CLR P3_7
NOP
NOP
NOP
SETB P3_7
MOV R3,#09
RE10:
DJNZ R3,RE10
MOV C,P3_7
MOV R3,#23
RE20:
DJNZ R3,RE20
RRC A
DJNZ R2,RE01
MOV @R1,A
DEC R1
DJNZ R4,RE00
#pragma endasm
}
void Delay_510(void) //延时510微秒
{
#pragma asm
MOV R0,#7DH
MOV R1,#02H
TSR1:
DJNZ R0,TSR1
MOV R0,#7DH
DJNZ R1,TSR1
#pragma endasm
}
void Delay_110(void) //延时110微秒
{
#pragma asm
MOV R0,#19H
MOV R1,#02H
TSR2:
DJNZ R0,TSR2
MOV R0,#19H
DJNZ R1,TSR2
#pragma endasm
}
void Delay_10ms(void) //延时10ms
{
#pragma asm
MOV R0,#19H
MOV R1,#0C8H
TSR3:
DJNZ R0,TSR3
MOV R0,#19H
DJNZ R1,TSR3
#pragma endasm
}
void Delay_4s(void) //延时4s
{
#pragma asm
MOV R2,#28H
TSR5:
MOV R0,#0FAH
MOV R1,#0C8H
TSR4:
DJNZ R0,TSR4
MOV R0,#0FAH
DJNZ R1,TSR4
DJNZ R2,TSR5
#pragma endasm
}
|