關(guān) 閉

新聞中心

EEPW首頁 > 工控自動化 > 設(shè)計應(yīng)用 > 電腦可調(diào)溫度控制器源程序

電腦可調(diào)溫度控制器源程序

作者: 時間:2011-05-18 來源:網(wǎng)絡(luò) 收藏

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 //發(fā)出4EH寫ROM指令后連發(fā)兩個字節(jié)分別為上下限
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
}

本文引用地址:http://butianyuan.cn/article/162078.htm

上一頁 1 2 3 下一頁

評論


相關(guān)推薦

技術(shù)專區(qū)

關(guān)閉