📄 jiashiqi.asm
字号:
;**********************************************
.chip tm8726
.HEAD
;**************************************************************************
;Display address
TemperatureDisH equ 03h
TemperatureDisM equ 011h
TemperatureDisL equ 012h
;***************************************
;
ReadRR equ 0001B
ReadRT equ 0010B
ReadComplete equ 1000B
Rr_rt equ 0001b
Rr_rh equ 0010b
TemperatureTabAddressL equ 00h
TemperatureTabAddressH equ 00h
;**************************************************************************
.ENDH
;**************************************************************************
;**************************************************************************
;**************************************************************************
.DATA
;**************************************************************************
org 00H
SecondCounter dn 1
TemperatureC0 dn 1
TemperatureC1 dn 1 ;温度数值
;***************************************
org 10H
;***************************************
org 20H
ACC dn 1
CF dn 1
C_TIME1 dn 1
C_TIME2 dn 1
RrRFC0 dn 1
RrRFC1 dn 1
RrRFC2 dn 1
RrRFC3 dn 1
RtRFC0 dn 1
RtRFC1 dn 1
RtRFC2 dn 1
RtRFC3 dn 1
Result5 dn 1
Result4 dn 1
Result3 dn 1
Result2 dn 1
Result1 dn 1
Result0 dn 1
Result_rt3 dn 1
Result_rt2 dn 1
Result_rt1 dn 1
Result_rt0 dn 1
Result_rh4 dn 1
Result_rh3 dn 1
Result_rh2 dn 1
Result_rh1 dn 1
Result_rh0 dn 1
read_th dn 1
IntFlag dn 1
humidity_disp_H1_Lo_Co dn 1
humidity_disp_h dn 1
humidity_disp_l dn 1 ;显示湿度
TemperatureTableAddrL dn 1
TemperatureTableAddrH dn 1
TemperatureTableAddrF dn 1
;----------------------------------
timer_hour_h dn 1
timer_hour_l dn 1
time_hour_1 dn 1
time_hour_2 dn 1
time_hour_3 dn 1
time_hour_4 dn 1
;----------------------------------
timer_1 dn 1
;***************************************
buz_time dn 1
Shortage_time dn 1 ;缺水时间
time_minute_1 dn 1
time_minute_2 dn 1
;***************************************
consumer_set_humitity_h dn 1
consumer_set_humitity_l dn 1 ;设定湿度
humitity_set_time dn 1 ;设定湿度,定时状态 数值显示时间
power_big dn 1 ;.0大小功率控制
;.1设定湿度时闪动
;.2开关机标志
;.3缺水标志
Schmitt_on_off dn 1 ;.0为施密特锁标志
;.1为是否达到设定状态标志
;.2连续加热标志
;.3缺水时闪动
delay_time dn 1 ;.0为定时关机标志
;
disp_no dn 1 ;.0湿度达到后,加湿显示关闭
;---------------------------------------
temp_2 dn 1 ;用于主程序
temp_3 dn 1 ;timer1中断中使用
temp_4 dn 1
temp_5 dn 1
;***************************************
disp_all_time dn 1 ;全部显示时间
;---------------------------------------
org 70H
TempZero dn 1
TempReg dn 10
temp_1 dn 2 ;用于KEY_PART
temp_6 dn 1 ;用于中断1
;**************************************************************************
.ENDD
;**************************************************************************
;**************************************************************************
;**************************************************************************
.CODE
;**************************************************************************
; reset and interrupt vector
;**************************************************************************
org 00H
jmp Reset
;************************************************************************
;************************************************************************
org 18H
jmp Timer1Interrupt
;************************************************************************
;************************************************************************
org 20H
jmp Timer2Interrupt
;************************************************************************
;************************************************************************
Timer1Interrupt:
sta ACC
maf CF
;------------------------buz time
lda buz_time
jz buz_off
alm 011000000b
dec* buz_time
jmp buz_out
buz_off:
alm 00h
buz_out:
;------------------------disp_all_time
lda disp_all_time
jz disp_all_out
dec* disp_all_time
disp_all_out:
;------------------------0.2s标志!0.015625*13=0.203125S
inc* timer_1
lds temp_3,13
sub timer_1
jz timer_1min
jmp timer_1min_out
timer_1min:
lda humitity_set_time
jz timer_1min_out
dec* humitity_set_time
timer_1min_out:
;------------------------Shortage of water
Shortage_water:
ipb temp_3
jb0 Shortage_water_1
lds temp_3,1000b
or* power_big
jmp Shortage_water_out
Shortage_water_1:
lds Shortage_time,15 ;缺水十五分钟后,关闭风扇
lds time_minute_1,0
lds time_minute_2,0
lds temp_3,0111b
and* power_big
jmp Shortage_water_out
Shortage_water_out:
;------------------------load_control ;temp_6.0背灯,.1小功率,.2大功率,.3为风扇
load_control:
lda power_big
jb2 load_control_1 ;是否开机
lda disp_all_time
jz off_control_1 ;开机背灯亮的时间
lds temp_6,0001b
jmp off_control_2
off_control_1:
lds temp_6,0
off_control_2:
opd temp_6
jmp load_control_out_1
;------------------
load_control_1:
lds temp_6,0001b ;背灯常亮
lda humitity_set_time ;设定结束后才执行操作
jnz load_control_out
lda Schmitt_on_off
jb2 load_control_1_1 ;连续加湿
lda Schmitt_on_off
jb1 load_control_1_1 ;需要加湿
andi* temp_6,1001b ;不需要加湿,则关闭加热大和小
jmp load_control_3
;----------------控制功率
load_control_1_1:
ori* temp_6,1011b ;开机状态小功率,振荡器和背灯常亮
lda power_big ;是否处于大功率状态
jb0 load_control_1_1_1
jmp load_control_3
load_control_1_1_1:
ori* temp_6,0100b
jmp load_control_3
;----------------;是否处于缺水状态
load_control_3:
lda power_big
jb3 load_control_3_1
jmp load_control_out_1
load_control_3_1: ;缺水
andi* temp_6,1001b
lda Shortage_time
jnz load_control_out_1
andi* temp_6,0111b
;----------------
load_control_out_1:
opd temp_6
jmp load_control_out_2
load_control_out:
ipd temp_6
ori* temp_6,0001b
opd temp_6
load_control_out_2:
;------------------------Schmitt_on_off
compare_1:
lda IntFlag
jb3 compare_out ;计算湿度和温度为完成时不比较
lda humitity_set_time ;设定结束后才执行比较操作
jnz compare_out
lda humidity_disp_l
sub consumer_set_humitity_l
sta temp_3
lda humidity_disp_h
sbc consumer_set_humitity_h
sta temp_4
jnc compare_3 ;consumer_set<humidity_disp,停止加热
compare_2:
lds temp_5,5
sub temp_3
lds temp_5,0
sbc temp_4
jc compare_4
lda Schmitt_on_off
jb0 compare_out ;如果没有超过过设定湿度,则继续加热
jmp compare_4
compare_3: ;湿度大于设定数值,则停止加湿
lds temp_5,1110b ;关闭加湿标志显示
and* disp_no
lds temp_5,1101b
and* Schmitt_on_off
lds temp_5,0001b
or* Schmitt_on_off ;置已经超过设定标志
jmp compare_out
compare_4:
lds temp_5,0001b
or* disp_no ;打开加湿标志显示
lds temp_5,0010b
or* Schmitt_on_off
lds temp_5,1110b
and* Schmitt_on_off
jmp compare_out
compare_out:
;------------------------
mra CF
lda ACC
sie* 0010010B
rts
;************************************************************************
;************************************************************************
Timer2Interrupt:
sta ACC
maf CF
;-------------------
lda C_TIME2
jz T_Arrive_1
lda C_TIME1
jz count_time1
dec* C_TIME1
jmp IntRet
count_time1:
dec* C_TIME2
lds C_TIME1,15
jmp IntRet
T_Arrive_1:
dec* C_TIME1
jnc T_Arrive
jnz IntRet
rf2 010B ;The last overflow clear the DED flag
jmp IntRet ;DED flag to enable timer control counter
T_Arrive:
srf 1 ;STOP RFC counter
mrf1 RrRFC0 ;Read the content of counter
mrf2 RrRFC1
mrf3 RrRFC2
mrf4 RrRFC3
lda IntFlag ;read RR?
jb0 StopTimer ;read RR jmp to rts (the last times)
call RrRFCToRtRFC ;(the first times)
lds IntFlag,ReadRR ;set read RR network flag
;-----------------------温度和湿度 时间切换
lda read_th
jb0 rt_time_1
rh_time_1:
lds C_TIME1,8 ;inernal couter to control timer2 overflow times
lds C_TIME2,1
jmp time_1
rt_time_1:
lds C_TIME1,7 ;inernal couter to control timer2 overflow times
lds C_TIME2,0
time_1:
;------------------------
srf 19H ;Build up the RR NetWork and enable counter
tm2x 7FH ;set PH3 as the clock sourceof timer1 and the down
;count balue is 3fh
sf2 0011B ;enable timer1 re-load and set DED flag
jmp IntRet
StopTimer:
lds IntFlag,ReadComplete;set start calculate flag and off timer2
rf2 011b ;disable re-load timer1
IntRet:
mra CF
lda ACC
sie* 0010010B
rts
;***************************************
RrRFCToRtRFC:
lda RrRFC0
sta RtRFC0
lda RrRFC1
sta RtRFC1
lda RrRFC2
sta RtRFC2
lda RrRFC3
sta RtRFC3
rts
;**************************************************************************
;**************************************************************************
EnableTimer2ToTestTemperature:
lda read_th
jb0 EnableTimer2ToTestTemperature_2
jb1 EnableTimer2ToTestTemperature_1
rts
EnableTimer2ToTestTemperature_1: ;温度
lds read_th,Rr_rt ;
lds IntFlag,ReadRT ;Set Read RT oscillation NetWork flag
sf 10B ;Set BCF flag
srf 1AH ;Build up the RT NetWork and enable counter
lds C_TIME1,7 ;inernal couter to control timer2 overflow times
lds C_TIME2,0
jmp EnableTimer2ToTestTemperature_3
EnableTimer2ToTestTemperature_2: ;湿度
lds read_th,Rr_rh ;
lds IntFlag,ReadRT ;Set Read RT oscillation NetWork flag
sf 10B ;Set BCF flag
srf 1CH ;Build up the RH NetWork and enable counter
lds C_TIME1,8 ;inernal couter to control timer2 overflow times
lds C_TIME2,1
jmp EnableTimer2ToTestTemperature_3
EnableTimer2ToTestTemperature_3:
TM2X 7fH ;?=8/32768
sf2 0011B ;enable timer 1,2 re-load and set DED flag
rts
;**************************************************************************
;**************************************************************************
CalculateTemperature:
lda IntFlag ;Is data for test ready?
jb3 TestNow ;Ready
rts
TestNow:
sf 10B ;set BCF flag for fast clock
call DivideFun
call GetTemperatureFromTab ;get Temperature from table
call DispTemperatureCF ;Display Temperature
rts
;**************************************************************************
;name: DivideFun
;input:RtRFC2,RtRFC1,RtRFC0 (RT NetWork content of counter)
;input:RrRFC2,RrRFC1,RrRFC0 (RR NetWork content of counter)
;ouput:Result3,Result2,Result1,Result0,
; (RrRFC2~0*4096)/RtRFC2~1~0=Result3~0
;**************************************************************************
DivideFun:
lds TempReg+8,00h
mrw TempReg+7,RrRFC3
mrw TempReg+6,RrRFC2
mrw TempReg+5,RrRFC1
mrw TempReg+4,RrRFC0
DivideFunCheck:
lda RtRFC0
or RtRFC1
or RtRFC2
or RtRFC3
jnz RealDivide
;-------------------------------------------------
TemperatureReadCountOver:
lda read_th ;
jb1 TemperatureReadCountOver_rh
lds Result_rt3,00h
lds Result_rt2,00h
lds Result_rt1,00h
lds Result_rt0,00h
rts
TemperatureReadCountOver_rh:
lds Result_rh4,00h
lds Result_rh3,00h
lds Result_rh2,00h
lds Result_rh1,00h
lds Result_rh0,00h
rts ;divide 0 Return
;--------------------------------------------------
RealDivide:
call TempReg7To4_SubRtRFC
mwr Result5,TempReg+1
mwr Result4,TempReg+2
mwr Result3,TempReg+3
call TempRegShiftLeft
call TempReg7To4_SubRtRFC
mwr Result2,TempReg+3 ;*16
call TempRegShiftLeft
call TempReg7To4_SubRtRFC
mwr Result1,TempReg+3 ;*16
lda read_th ;如果为测温则乘以4096,如果测试湿度则乘以256
jb1 RealDivide_end_1
call TempRegShiftLeft
call TempReg7To4_SubRtRFC
mwr Result0,TempReg+3 ;*16
RealDivide_end:
lda Result3 ;温度结果
sta Result_rt3
lda Result2
sta Result_rt2
lda Result1
sta Result_rt1
lda Result0
sta Result_rt0
rts
RealDivide_end_1:
lda Result5 ;湿度结果
sta Result_rh4
lda Result4
sta Result_rh3
lda Result3
sta Result_rh2
lda Result2
sta Result_rh1
lda Result1
sta Result_rh0
rts
;**********************************************
TempRegShiftLeft:
mrw TempReg+8,TempReg+7
mrw TempReg+7,TempReg+6
mrw TempReg+6,TempReg+5
mrw TempReg+5,TempReg+4
lds TempReg+4,00h
rts
;**********************************************
;name: TempReg7To4_SubRtRFC
;input: TempReg+4,TempReg+5,TempReg+6,TempReg+7
;input: RtRFC2,RtRFC1,RtRFC0,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -