DS18B20數碼管與液晶1602顯示溫度和控制
大小:0.2 MB 人氣: 2017-09-06 需要積分:0
????????? TIMER_H???? DATA? 24H
????????? TIMER_COUN? DATA? 25H
????????? TEMPL?????? DATA? 26H
????????? TEMPH?????? DATA? 27H
????????? TEMP_TH???? DATA? 28H
????????? TEMP_TL???? DATA? 29H
????????? TEMPHC????? DATA? 2AH
????????? TEMPLC????? DATA? 2BH
????????? TEMP_ZH???? DATA? 2CH
????????? BEEP??????? EQU?? P3.7
????????? DATA_LINE?? EQU?? P3.3
????????? RELAY?????? EQU?? P1.3
????????? FLAG1?????? EQU?? 20H.0
????????? FLAG2?????? EQU?? 20H.1
;-------------------------------------------------
????????? K1?? EQU? P1.4
????????? K2?? EQU? P1.5
????????? K3?? EQU? P1.6
????????? K4?? EQU? P1.7
;=================================================
????????? ORG 0000H
????????? JMP? MAIN
????????? ORG? 000BH
????????? AJMP? INT_T0
;--------------------------------------------------
MAIN:???? MOV SP,#30H
????????? MOV? TMOD,#01H??????? ;T0,方式1
????????? MOV? TIMER_L,#00H???? ;50ms定時值
????????? MOV? TIMER_H,#4CH
????????? MOV? TIMER_COUN,#00H? ;中斷計數
????????? MOV? IE,#82H????????? ;EA=1,ET0=1
????????? LCALL? READ_E2
????????? ;LCALL? RE_18B20
????????? MOV? 20H,#00H
????????? SETB?? BEEP
????????? SETB?? RELAY
????????? MOV? 7FH,#0AH???????? ;熄滅符
????????? CALL RESET??????????? ;復位與檢測DS18B20
????????? JNB FLAG1,MAIN1?????? ;FLAG1=0,DS18B20不存在
????????? JMP? START
MAIN1:??? CALL RESET
????????? JB FLAG1,START
????????? LCALL? BEEP_BL??????? ;DS18B20錯誤,報警
????????? JMP? MAIN1
START:
????????? MOV A,#0CCH???????? ; 跳過ROM匹配
????????? CALL WRITE
????????? MOV A,#044H???????? ; 發出溫度轉換命令
????????? CALL WRITE
????????? CALL RESET
????????? MOV A,#0CCH???????? ; 跳過ROM匹配
????????? CALL WRITE
????????? MOV A,#0BEH???????? ; 發出讀溫度命令
????????? CALL WRITE
????????? CALL? READ?????????? ;讀溫度數據
????????? CALL? CONVTEMP
????????? CALL? DISPBCD
????????? CALL? DISP1
????????? CALL? SCANKEY
????????? LCALL? TEMP_COMP
????????? JMP?? MAIN1
;=====================================================
;DS18B20 復位與檢測子程序
;FLAG1=1 OK, FLAG1=0 ERROR
;======================================================
RESET:
????????? SETB DATA_LINE
????????? NOP
????????? CLR DATA_LINE
????????? MOV R0,#64H??????????? ;主機發出延時600微秒的復位低脈沖
????????? MOV R1,#03H
RESET1:?? DJNZ R0,$
????????? MOV R0,#64H
????????? DJNZ R1,RESET1
????????? SETB DATA_LINE??????? ;然后拉高數據線
????????? NOP
????????? MOV R0,#25H
RESET2:?? JNB DATA_LINE,RESET3? ;等待DS18B20回應
????????? DJNZ R0,RESET2
????????? JMP RESET4??????????? ; 延時
RESET3:?? SETB FLAG1??????????? ; 置標志位,表示DS1820存在
????????? JMP RESET5
RESET4:?? CLR FLAG1???????????? ; 清標志位,表示DS1820不存在
????????? JMP RESET6
RESET5:?? MOV R0,#064H
????????? DJNZ R0,$???????????? ; 時序要求延時一段時間
RESET6:?? SETB DATA_LINE
????????? RET
;===========================================================
;
;===========================================================
WRITE:? MOV R2,#8??????????? ;一共8位數據
??????? CLR CY
WR1:
??????? CLR DATA_LINE??????? ;開始寫入DS18B20總線要處于復位(低)狀態
??????? MOV R3,#09
??????? DJNZ R3,$??????????? ;總線復位保持18微妙以上
??????? RRC A??????????????? ;把一個字節DATA 分成8個BIT環移給C
??????? MOV DATA_LINE,C????? ;寫入一個BIT
??????? MOV R3,#23
??????? DJNZ R3,$??????????? ;等待46微妙
??????? SETB DATA_LINE?????? ;重新釋放總線
??????? NOP
??????? DJNZ R2,WR1????????? ;寫入下一個BIT
??????? SETB DATA_LINE
??????? RET
;============================================================
;從DS18B20中讀出溫度低位、高位和報警值TH、TL
;存入26H、27H、28H、29H
;============================================================
READ:??? MOV R4,#4??????????? ; 將溫度高位和低位從DS18B20中讀出
???????? MOV R1,#26H????????? ; 存入26H、27H、28H、29H
RE00:??? MOV R2,#8
RE01:??? CLR C
???????? SETB DATA_LINE
???????? NOP
???????? NOP
???????? CLR DATA_LINE??????? ;讀前總線保持為低
???????? NOP
???????? NOP
???????? NOP
???????? SETB DATA_LINE?????? ;開始讀總線釋放
???????? MOV R3,#09?????????? ;延時18微妙
???????? DJNZ R3,$
???????? MOV C,DATA_LINE????? ;從DS18B20總線讀得一個BIT
???????? MOV R3,#23
???????? DJNZ R3,$??????????? ;等待46微妙
???????? RRC A??????????????? ;把讀得的位值環移給A
???????? DJNZ R2,RE01???????? ;讀下一個BIT
???????? MOV @R1,A
???????? INC R1
???????? DJNZ R4,RE00
???????? RET????????
;--------------------------------------------
;200ms對閃動標記取反一次
;--------------------------------------------
INT_T0:
????????? PUSH? ACC
????????? PUSH? PSW
????????? MOV? TL0,TIMER_L
????????? MOV? TH0,TIMER_H
????????? INC? TIMER_COUN
????????? MOV? A,TIMER_COUN
????????? CJNE? A,#04H,INT_END
????????? MOV? TIMER_COUN,#00H
????????? CPL? FLAG2
INT_END:
????????? POP? PSW
????????? POP? ACC
????????? RETI
;==========================================================
;重新對 DS18B20 初始化
;將設定的溫度報警值寫入 DS18B20
;==========================================================
RE_18B20:
??????? JB? FLAG1,RE_18B20A
??????? RET
RE_18B20A:
??????? CALL? RESET
??????? MOV? A,#0CCH?????? ;跳過ROM匹配
??????? LCALL? WRITE
??????? MOV? A,#4EH??????? ;寫暫存寄存器
??????? LCALL? WRITE
??????? MOV? A,TEMP_TH???? ;TH(報警上限)
??????? LCALL? WRITE
??????? MOV? A,TEMP_TL???? ;TL(報警下限)
??????? LCALL? WRITE
??????? MOV? A,#7FH??????? ;12位精確度
??????? LCALL? WRITE
??????? RET
;====================================================
;功能鍵掃描子程序
;====================================================
SCANKEY:
????????????? MOV? P1,#0F0H
????????????? JB? K1,SCAN_K2
????????????? CALL? BEEP_BL
SCAN_K1:????? CALL? ALERT_TL
????????????? CALL? ALERT_PLAY
????????????? JB?? K1,SCAN_K1
????????????? CALL? BEEP_BL
SCAN_K11:???? CALL? ALERT_TH
????????????? CALL? ALERT_PLAY
????????????? JB??? K1,SCAN_K11
????????????? CALL? BEEP_BL
SCAN_K2:????? JB? K2,SCAN_K3
????????????? CALL? BEEP_BL
SCAN_K3:????? JB? K3,SCAN_K4
????????????? CALL? BEEP_BL
????????????? LCALL? RESET_ALERT
????????????? LCALL? RE_18B20
????????????? LCALL? WRITE_E2
SCAN_K4:????? JB? K4,SCAN_END
????????????? CALL? BEEP_BL
SCAN_END:???? RET
;================================================
;設置溫度報警值
;================================================
RESET_ALERT:
????????? CALL? ALERT_TL
????????? CALL? ALERT_PLAY
????????? JNB K3,$????????????? ;K3為位移鍵
????????? SETB? TR0
RESET_TL:
????????? CALL? ALERT_PLAY
????????? JNB? FLAG2,R_TL01
????????? mov? 75H,7fh????????? ;送入熄滅符
????????? mov? 76H,7fh
????????? CALL? ALERT_PLAY
????????? JMP?? R_TL02
R_TL01:?? CALL? ALERT_TL
????????? mov? 75h,7Eh????????? ;送設定值
????????? mov? 76h,7Dh
????????? CALL? ALERT_PLAY????? ;顯示設定值
R_TL02:?? JNB? K1,K011A
????????? JNB? K2,K011B
????????? JNB? K3,RESET_TH
????????? JMP? RESET_TL
K011A:
????????? INC? TEMP_TL
????????? MOV? A,TEMP_TL
????????? CJNE? A,#120,K012A??? ;沒有到設定上限值,轉
????????? MOV? TEMP_TL,#0
K012A:??? CALL? TL_DEL
????????? JMP?? RESET_TL
K011B:
????????? DEC? TEMP_TL
????????? MOV? A,TEMP_TL
????????? CJNE? A,#00H,K012B?? ;沒有到設定下限值,轉
????????? MOV? TEMP_TL,#119
K012B:??? CALL? TL_DEL
????????? JMP?? RESET_TL
;-------------------------------------------------------
RESET_TH:
?????????? CALL? BEEP_BL
?????????? JNB? K3,$
RESET_TH1:
????????? CALL? ALERT_PLAY
????????? JNB? FLAG2,R_TH01
????????? mov? 75H,7fh????????? ;送入熄滅符
????????? mov? 76H,7fh
????????? CALL? ALERT_PLAY
????????? JMP?? R_TH02
R_TH01:?? CALL? ALERT_TH
????????? mov? 75h,7Eh????????? ;
????????? mov? 76h,7Dh
????????? CALL? ALERT_PLAY
R_TH02:?? JNB? K1,K021A
????????? JNB? K2,K021B
????????? JNB? K3,K002
????????? JMP? RESET_TH1
K021A:
????????? INC? TEMP_TH
????????? MOV? A,TEMP_TH
????????? CJNE? A,#120,K022A?? ;沒有到設定上限值,轉
????????? MOV? TEMP_TH,#0
K022A:???? CALL? TH_DEL
????????? JMP?? RESET_TH1
K021B:
????????? DEC? TEMP_TH???????? ;減1
????????? MOV? A,TEMP_TH
????????? CJNE? A,#00H,K022B?? ;沒有到設定下限值,轉
????????? MOV? TEMP_TH,#119
K022B:??? CALL? TH_DEL
????????? JMP?? RESET_TH1
K002:???? CALL? BEEP_BL
????????? CLR? TR0???????????? ;關閉中斷
????????? RET
;-----------------------------------------------------
;鍵延時子程序
;多次調用報警值顯示程序來延時
;-----------------------------------------------------
TL_DEL:??????????????????????? ;報警低值延時
????????? MOV? R2,#0AH
TL_DEL1:? CALL? ALERT_TL
????????? CALL? ALERT_PLAY
????????? DJNZ? R2,TL_DEL1
????????? RET
TH_DEL:??????????????????????? ;報警高值延時
????????? MOV? R2,#0AH
TH_DEL1:? CALL? ALERT_TH
????????? CALL? ALERT_PLAY
????????? DJNZ? R2,TH_DEL1
????????? RET
;====================================================
;實時溫度值與設定報警溫度值 TH、TL 比較子程序
;當實際溫度大于 TH 的設定值時,顯示“H”,繼電器關閉。
;當實際溫度小于 TH 的設定值時,顯示“O”,繼電器吸合。
;當實際溫度小于 TL 的設定值時,顯示“L”。
;閃動顯示標記符 H、L、O
;====================================================
TEMP_COMP:
????????? SETB? TR0???????????? ;啟動中斷
????????? MOV? A,TEMP_TH
????????? SUBB? A,TEMP_ZH?????? ;減數>被減數,則
????????? JC? CHULI1??????????? ;借位標志位C=1,轉
????????? MOV? A,TEMP_ZH
????????? SUBB? A,TEMP_TL?????? ;減數>被減數,則
????????? JC? CHULI2??????????? ;借位標志位C=1,轉
????????? JNB? FLAG2,T_COMP1??? ;FLAG2=0,顯示標記字符
????????? MOV? 74H,#0AH???????? ;熄滅符
????????? LCALL? DISP1
????????? JMP? T_COMP2
T_COMP1:? MOV? 74H,#00H
????????? LCALL? DISP1????????? ;顯示"O"
T_COMP2:? CLR?? RELAY?????????? ;繼電器吸合
????????? CLR? TR0????????????? ;關閉中斷
????????? RET
;---------------------------------------------
;超溫處理
;---------------------------------------------
CHULI1:
????????? SETB? RELAY?????????? ;繼電器關閉
????????? JNB? FLAG2,CHULI10
????????? MOV? 74H,#0AH???????? ;熄滅符
????????? LCALL? DISP1
????????? JMP? CHULI11
CHULI10:? MOV? 74H,#0DH?????????
????????? LCALL? DISP1????????? ;顯示"H"
????????? ;CALL? BEEP_BL??????? ;蜂鳴器響
CHULI11:
????????? CLR? TR0????????????? ;關閉中斷
????????? RET
;---------------------------------------------
;欠溫處理
;---------------------------------------------
CHULI2:???????????????????????? ;欠溫處理
????????? JNB? FLAG2,CHULI20
????????? MOV? 74H,#0AH???????? ;熄滅符
????????? LCALL? DISP1
????????? JMP? CHULI21
CHULI20:? MOV? 74H,#0CH?????????
????????? LCALL? DISP1????????? ;顯示"L"
????????? ;CALL? BEEP_BL??????? ;蜂鳴器響
CHULI21:? CLR? TR0????????????? ;關閉中斷
????????? RET
;------------------------------------------------------------
;把 DS18B20 暫存器里的溫度報警值拷貝到EEROM
;------------------------------------------------------------
WRITE_E2:
??????? CALL? RESET
??????? MOV? A,#0CCH??????? ;跳過ROM匹配
??????? LCALL? WRITE
??????? MOV? A,#48H???????? ;溫度報警值拷貝到EEROM
??????? LCALL? WRITE
??????? RET
;--------------------------------------------------------------
;把 DS18B20 EEROM 里的溫度報警值拷貝回暫存器
;-------------------------------------------------------------
READ_E2:
??????? CALL? RESET
??????? MOV? A,#0CCH??????? ;跳過ROM匹配
??????? LCALL? WRITE
??????? MOV? A,#0B8H??????? ;溫度報警值拷貝回暫存器
??????? CALL? WRITE
??????? RET
;*****************************************************
;? 處理溫度 BCD 碼子程序
;****************************************************
CONVTEMP:????? MOV? A,TEMPH?????? ;判溫度是否零下
?????????????? ANL? A,#80H
?????????????? JZ? TEMPC1???????? ;溫度零上轉
?????????????? CLR? C
?????????????? MOV? A,TEMPL?????? ;二進制數求補(雙字節)
?????????????? CPL? A???????????? ;取反加1
?????????????? ADD? A,#01H
?????????????? MOV? TEMPL,A
?????????????? MOV? A,TEMPH?????? ;-
?????????????? CPL? A
?????????????? ADDC? A,#00H
?????????????? MOV? TEMPH,A????????? ;TEMPHC HI =符號位
?????????????? MOV? TEMPHC,#0BH
?????????????? SJMP? TEMPC11
TEMPC1:??????? MOV? TEMPHC,#0AH???? ;
TEMPC11:?????? MOV? A,TEMPHC
?????????????? SWAP? A
?????????????? MOV? TEMPHC,A
?????????????? MOV? A,TEMPL
?????????????? ANL? A,#0FH???????????? ;乘0.0625
?????????????? MOV? DPTR,#TEMPDOTTAB
?????????????? MOVC? A,@A+DPTR
?????????????? MOV? TEMPLC,A??????????? ;TEMPLC? LOW=小數部分 BCD
?????????????? MOV? A,TEMPL???????????? ;整數部分
?????????????? ANL? A,#0F0H
?????????????? SWAP? A
?????????????? MOV? TEMPL,A
?????????????? MOV? A,TEMPH
?????????????? ANL? A,#0FH
?????????????? SWAP? A
?????????????? ORL? A,TEMPL
?????????????? MOV? TEMP_ZH,A?????????? ;組合后的值存入TEMP_ZH
?????????????? LCALL? HEX2BCD1
?????????????? MOV? TEMPL,A
?????????????? ANL? A,#0F0H
?????????????? SWAP? A
?????????????? ORL? A,TEMPHC??????????? ;TEMPHC LOW = 十位數 BCD
?????????????? MOV? TEMPHC,A
?????????????? MOV? A,TEMPL
?????????????? ANL? A,#0FH
?????????????? SWAP? A????????????????? ;TEMPLC HI = 個位數 BCD
?????????????? ORL? A,TEMPLC
?????????????? MOV? TEMPLC,A
?????????????? MOV? A,R7
?????????????? JZ? TEMPC12
?????????????? ANL? A,#0FH
?????????????? SWAP? A
?????????????? MOV? R7,A
?????????????? MOV? A,TEMPHC??????????? ;TEMPHC HI = 百位數 BCD
?????????????? ANL? A,#0FH
?????????????? ORL? A,R7
?????????????? MOV? TEMPHC,A
TEMPC12:?????? RET
;-----------------------------------------------------------
;? 小數部分碼表
;-----------------------------------------------------------
TEMPDOTTAB:? DB?? 00H,01H,01H,02H,03H,03H,04H,04H,05H,06H
???????????? DB?? 06H,07H,08H,08H,09H,09H
;===========================================================
;顯示區 BCD 碼溫度值刷新子程序
;===========================================================
DISPBCD:????? MOV? A,TEMPLC
????????????? ANL? A,#0FH
????????????? MOV? 70H,A???????????????? ;小數位
????????????? MOV? A,TEMPLC
????????????? SWAP? A
????????????? ANL? A,#0FH
????????????? MOV? 71H,A???????????????? ;個位
????????????? MOV? A,TEMPHC
????????????? ANL? A,#0FH
????????????? MOV? 72H,A???????????????? ;十位
????????????? MOV? A,TEMPHC
????????????? SWAP? A
????????????? ANL? A,#0FH
????????????? MOV? 73H,A???????????????? ;百位
????????????? MOV? A,TEMPHC
????????????? ANL? A,#0F0H
????????????? CJNE? A,#010H,DISPBCD0
????????????? SJMP? DISPBCD2
DISPBCD0:???? MOV? A,TEMPHC
????????????? ANL? A,#0FH
????????????? JNZ? DISPBCD2?????????????? ;十位數是0
????????????? MOV? A,TEMPHC
????????????? SWAP? A
????????????? ANL? A,#0FH
????????????? MOV? 73H,#0AH?????????????? ;符號位不顯示
????????????? MOV? 72H,A????????????????? ;十位數顯示符號
DISPBCD2:???? RET
;***************************************************************
;???? 溫度顯示子程序
;***************************************************************
;顯示數據在70H - 73H 單元內,用4位共陽數碼管顯示,P0口輸出段碼數據,
;P2 口作掃描控制,每個 LED 數碼管亮 2MS 時間再逐位循環。
DISP1:?????? MOV? R1,#70H???????????? ;指向顯示數據首址
???????????? MOV? R5,#7FH??????????? ;掃描控制字初值
PLAY:??????? MOV? P0,#0FFH
???????????? MOV? A,R5??????????????? ;掃描字放入A
???????????? MOV? P2,A
???????????? MOV? A,@R1?????????????? ;取顯示數據到A
???????????? MOV? DPTR,#TAB?????????? ;取段碼表地址
???????????? MOVC? A,@A+DPTR????????? ;查顯示數據對應段碼
???????????? MOV? P0,A??????????????? ;段碼放入P0口
???????????? MOV? A,R5
???????????? JB?? ACC.6,LOOP5???????? ;小數點處理
???????????? CLR? P0.7
LOOP5:?????? LCALL? DL_MS????????????? ;顯示2MS
???????????? INC? R1?????????????????? ;指向下一個地址
???????????? MOV? A,R5???????????????? ;放回 R5 內
???????????? JNB? ACC.3,ENDOUT??????? ;ACC.3=0時一次顯示結束
???????????? RR? A??????????????????? ;A 中數據循環左移
???????????? MOV? R5,A??????????????? ;放入 R5 中
???????????? AJMP? PLAY?????????????? ;跳回 PLAY 循環
ENDOUT:????? MOV? P0,#0FFH??????????? ;一次顯示結束,P0口復位
???????????? MOV? P2,#0FFH??????????? ;P2口復位
???????????? RET
TAB:
?DB? 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,0FFH,0BFH,0C7H,89H
;?? “0"? “1" “2" “3" “4"“5"“6"“7"“8"“9"“滅" “-" “L”“H"
DL_MS:????? MOV? R6,#0AH???????? ;2MS延時程序,LED 顯示程序用
DL1:??????? MOV? R7,#64H
DL2:??????? DJNZ? R7,DL2
??????????? DJNZ? R6,DL1
??????????? RET
;******************************************************
;單字節十六進制轉 BCD
;******************************************************
HEX2BCD1:?? MOV? B,#064H??????????
??????????? DIV? AB???????????????
??????????? MOV? R7,A?????????????
??????????? MOV? A,#0AH
??????????? XCH? A,B
??????????? DIV? AB???????????????
??????????? SWAP? A
??????????? ORL? A,B
??????????? RET
;===============================================
;報警值 TH、TL 數據轉換
;===============================================
ALERT_TL:
???????????? MOV? 79H,#0CH
???????????? MOV? 78H,#0BH
???????????? MOV? A,TEMP_TL
???????????? MOV? R0,#77H
???????????? MOV? B,#064H
???????????? DIV? AB
???????????? CJNE? A,#01H,ALERT_TL1
???????????? MOV? @R0,A
???????????? JMP? ALERT_TL2
ALERT_TL1:?? MOV? A,#0BH?????????? ;顯示“-”
???????????? MOV? @R0,A
ALERT_TL2:?? MOV? A,#0AH
???????????? XCH? A,B
???????????? DIV? AB
???????????? DEC? R0
???????????? MOV? @R0,A
???????????? MOV? 7DH,A
???????????? DEC? R0
???????????? MOV? @R0,B
???????????? MOV? 7EH,B
???????????? RET
;-----------------------------------------------
ALERT_TH:
???????????? MOV? 79H,#0DH
???????????? MOV? 78H,#0BH
???????????? MOV? A,TEMP_TH
???????????? MOV? R0,#77H
???????????? MOV? B,#064H
???????????? DIV? AB
???????????? CJNE? A,#01H,ALERT_TH1
???????????? MOV? @R0,A
???????????? JMP? ALERT_TH2
ALERT_TH1:?? MOV? A,#0BH???????????? ;顯示“-”
???????????? MOV? @R0,A
ALERT_TH2:?? MOV? A,#0AH
???????????? XCH? A,B
???????????? DIV? AB
???????????? DEC? R0
???????????? MOV? @R0,A
???????????? MOV? 7DH,A
???????????? DEC? R0
???????????? MOV? @R0,B
???????????? MOV? 7EH,B
???????????? RET
;===============================================
;報警值顯示子程序
;===============================================
ALERT_PLAY:
???????????? MOV? R1,#75H???????????? ;指向顯示數據首址
???????????? MOV? R5,#7FH??????????? ;掃描控制字初值
A_PLAY:????? MOV? P0,#0FFH
???????????? MOV? A,R5??????????????? ;掃描字放入A
???????????? MOV? P2,A
???????????? MOV? A,@R1?????????????? ;取顯示數據到A
???????????? MOV? DPTR,#ALERT_TAB???? ;取段碼表地址
???????????? MOVC? A,@A+DPTR????????? ;查顯示數據對應段碼
???????????? MOV? P0,A??????????????? ;段碼放入P0口
???????????? LCALL? DL_MS1??????????? ;顯示2MS
???????????? INC? R1????????????????? ;指向下一個地址
???????????? MOV? A,R5
???????????? JNB? ACC.3,ENDOUT1
???????????? RR? A??????????????????? ;A 中數據循環左移
???????????? MOV? R5,A??????????????? ;放入 R5 中
???????????? AJMP? A_PLAY???????????? ;跳回 PLAY 循環
ENDOUT1:???? MOV? P0,#0FFH??????????? ;一次顯示結束,P0口復位
???????????? MOV? P2,#0FFH??????????? ;P2口復位
???????????? RET
ALERT_TAB:
?DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,0FFH,0BFH,0C7H,89H
;共陽段碼表 “0"? “1" “2" “3" “4"“5"“6"“7"“8"“9"“滅" “-"
DL_MS1:????? MOV? R6,#0AH???????? ;2MS延時程序,LED 顯示程序用
ADL1:??????? MOV? R7,#64H
ADL2:??????? DJNZ? R7,ADL2
???????????? DJNZ? R6,ADL1
???????????? RET
;===============================================
;蜂鳴器響一聲子程序
;P3.7=0,蜂鳴器響
;===============================================
BEEP_BL:
???????? MOV? R6,#100
?BL2:??? CALL? DEX1
???????? CPL? BEEP??????? ;對 P3.7 取反
???????? DJNZ? R6,BL2
???????? MOV? R5,#10
???????? CALL? DELAY
???????? RET
?DEX1:?? MOV? R7,#180
?DE2:??? NOP
???????? DJNZ? R7,DE2
???????? RET
DELAY:??????????????????? ;(R5)*延時10MS
???????? MOV? R6,#50
?DEL1:?? MOV? R7,#100
???????? DJNZ? R7,$
???????? DJNZ? R6,DEL1
???????? DJNZ? R5,DELAY
???????? RET
;==================================================
???????? END
非常好我支持^.^
(4) 80%
不好我反對
(1) 20%