关于RC充放电实现温度检测例程
;*******************************************************************
; Function : 温度检测(用3个I/O口实现)
;*******************************************************************
temp_chk proc
clr Re_adl
clr Re_adh
clr rt_adl
clr rt_adh
clr chkRe_cnt
clr chkrt_cnt
temp_chk_re:
call temp_chk_fd
call tempchk_Re_cd
inc chkRe_cnt
mov a,chkRe_cnt
sub a,04h ;检测4次参考电阻
snz c
jmp temp_chk_re
temp_chk_rt:
call temp_chk_fd
call tempchk_rt_cd
inc chkrt_cnt
mov a,chkrt_cnt
sub a,08h ;检测8次热敏电阻
snz c
jmp temp_chk_rt
call temp_ad_cal
ret
temp_chk endp
;**********************
; 放电
;**********************
temp_chk_fd proc
clr pcc.0
clr pcc.1
clr pgc.0
clr Re_r
clr Rt_r
clr v_chk
tempchk_fd0:
snz flag_1ms
jmp tempchk_fd0
clr flag_1ms
call scanKey
call display
tempchk_fd1:
snz flag_1ms
jmp tempchk_fd1
clr flag_1ms
call scanKey
call display
ret
temp_chk_fd endp
;**********************
; 参考电阻充电
;**********************
tempchk_Re_cd proc
set pcc.1
set pgc.0
clr pcc.0
tempchk_Re_cd0:
snz flag_1ms
jmp tempchk_Re_cd0
clr flag_1ms
call display
set Re_r
mov a,tmr
mov tchk_tmr,a ;开始计时
tempchk_Re_cd1:
sz flag_1ms
jmp tempchk_Re_ad0
snz v_chk
jmp tempchk_Re_cd1
mov a,tmr
sub a,tchk_tmr
addm a,Re_adl
clr acc
adcm a,Re_adh
jmp tempchk_Re_ad1
tempchk_Re_ad0:
clr flag_1ms
mov a,255
sub a,tchk_tmr
addm a,Re_adl
clr acc
adcm a,Re_adh
jmp tempchk_Re_ok
tempchk_Re_ad1:
snz flag_1ms
jmp tempchk_Re_ad1
clr flag_1ms
tempchk_Re_ok:
call display
ret
tempchk_Re_cd endp
;**********************
; 热敏电阻充电
;**********************
tempchk_rt_cd proc
set pcc.0
set pgc.0
clr pcc.1
tempchk_rt_cd0:
snz flag_1ms
jmp tempchk_rt_cd0
clr flag_1ms
call display
set Rt_r
mov a,tmr
mov tchk_tmr,a ;开始计时
tempchk_rt_cd1:
sz flag_1ms
jmp tempchk_rt_ad0
snz v_chk
jmp tempchk_rt_cd1
mov a,tmr
sub a,tchk_tmr
addm a,rt_adl
clr acc
adcm a,rt_adh
jmp tempchk_rt_ad1
tempchk_rt_ad0:
clr flag_1ms
mov a,255
sub a,tchk_tmr
addm a,rt_adl
clr acc
adcm a,rt_adh
jmp tempchk_rt_ok
tempchk_rt_ad1:
snz flag_1ms
jmp tempchk_rt_ad1
clr flag_1ms
tempchk_rt_ok:
call display
ret
tempchk_rt_cd endp
;**********************
; 温度计算程序
;**********************
temp_ad_cal proc
mov a,rt_adl
mov ad_tmpl,a
mov a,rt_adh
mov ad_tmph,a
clr ad_cnt
clr temp_ad
rt_ad_loop:
mov a,ad_tmpl
addm a,rt_adl
clr acc
adcm a,rt_adh
mov a,ad_tmph
addm a,rt_adh
inc ad_cnt
mov a,ad_cnt
sub a,63
snz c
jmp rt_ad_loop
temp_ad_loop:
mov a,rt_adl
sub a,Re_adl
mov rt_adl,a
snz c
jmp tw
jmp sub_h
tw:
mov a,Re_adh
sub a,rt_adh
sz c
jmp temp_adcal_ok
dec rt_adh
sub_h:
mov a,rt_adh
sub a,Re_adh
mov rt_adh,a
snz c
jmp temp_adcal_ok
inc temp_ad
jmp temp_ad_loop
temp_adcal_ok:
ret
temp_ad_cal endp