he313sv1.asm
字号:
rjmp TimerDispLogic50
;-------Wait for time on run-----
lds r16 , TimeHourCnt
lds r17 , TimeMinCnt
lds r18 , TAOnHourCnt
lds r19 , TAOnMinCnt
sub r19 , r17
brcc TimerDispLogic10
ldi r22 , 60
add r19 , r22
inc r16
TimerDispLogic10:
sub r18 , r16
brcc TimerDispLogic15
ldi r22 , 24
add r18 , r22
TimerDispLogic15:
lds r16 , TimeHourCnt
lds r17 , TimeMinCnt
lds r20 , TBOnHourCnt
lds r21 , TBOnMinCnt
sub r21 , r17
brcc TimerDispLogic20
ldi r22 , 60
add r21 , r22
inc r16
TimerDispLogic20:
sub r20 , r16
brcc TimerDispLogic24
ldi r22 , 24
add r20 , r22
TimerDispLogic24:
sbrc SetByte , SetTimerA
sbrs SetByte , SetTimerB
rjmp TimerDisplogic30
;in timer A and B both set
cp r20 , r18
breq TimerDispLogic27
brcs TimerDispLogic26
;-------r20>r18-----
TimerDispLogic25:
lds r18 , TAOnHourCnt ;syg debug 9.21
lds r19 , TAOnMinCnt
sts TimerDispHour , r18
sts TimerDispMin , r19
rjmp TimerDispLogic90
TimerDispLogic26:
;--------r20<r18
lds r20 , TBOnHourCnt ;syg debug 9.21
lds r21 , TBOnMinCnt
sts TimerDispHour , r20
sts TimerDispMin , r21
rjmp TimerDispLogic90
TimerDispLogic27:
cp r21 , r19
brcs TimerDispLogic26 ;r21<r19
rjmp TimerDispLogic25
TimerDispLogic30:
sbrc SetByte , SetTimerA
rjmp TimerDisplogic25
rjmp TimerDisplogic26
TimerDispLogic50:
;-------wait of time off run---------------
lds r16 , TimeHourCnt
lds r17 , TimeMinCnt
lds r18 , TAOffHourCnt
lds r19 , TAOffMinCnt
sub r19 , r17
brcc TimerDispLogic60
ldi r22 , 60
add r19 , r22
inc r16
TimerDispLogic60:
sub r18 , r16
brcc TimerDispLogic65
ldi r22 , 24
add r18 , r22
TimerDispLogic65:
lds r16 , TimeHourCnt
lds r17 , TimeMinCnt
lds r20 , TBOffHourCnt
lds r21 , TBOffMinCnt
sub r21 , r17
brcc TimerDispLogic70
ldi r22 , 60
add r21 , r22
inc r16
TimerDispLogic70:
sub r20 , r16
brcc TimerDispLogic74
ldi r22 , 24
add r20 , r22
TimerDispLogic74:
sbrc RunByte, TARun
sbrs RunByte, TBRun
rjmp TimerDisplogic80
;in timer A and B both run
cp r20 , r18
breq TimerDispLogic77
brcs TimerDispLogic76
;-------r20>r18-----
TimerDispLogic75:
; lds r18 , TAOffHourCnt ;syg debug 9.21
; lds r19 , TAOffMinCnt
lds r18 , TBOffHourCnt ;syg debug 9.21
lds r19 , TBOffMinCnt
sts TimerDispHour , r18
sts TimerDispMin , r19
rjmp TimerDispLogic90
TimerDispLogic76:
;--------r20<r18
; lds r20 , TBOffHourCnt ;syg debug 9.21
; lds r21 , TBOffMinCnt
lds r20 , TAOffHourCnt ;syg debug 9.21
lds r21 , TAOffMinCnt
sts TimerDispHour , r20
sts TimerDispMin , r21
rjmp TimerDispLogic90
TimerDispLogic77:
cp r21 , r19
brcs TimerDispLogic76 ;r21<r19
rjmp TimerDispLogic75
TimerDispLogic80:
;sbrc RunByte, TARun
;rjmp TimerDisplogic76
;rjmp TimerDisplogic75
sbrs RunByte , TARun
rjmp TimerDispLogic85
;-------TARun---
sbrs SetByte , SetTimerB
rjmp TimerDispLogic76
;-------TARun , but TB have set---
lds r18 , TAOnHourCnt
lds r19 , TAOnMinCnt
lds r20 , TAOffHourCnt
lds r21 , TAOffMinCnt
lds r16 , TBOnHourCnt
lds r17 , TBOnMinCnt
lds r22 , TBOffHourCnt
lds r23 , TBOffMinCnt
rjmp CheckInlaid
TimerDispLogic85:
sbrs SetByte , SetTimerA
rjmp TimerDispLogic75
lds r18 , TBOnHourCnt
lds r19 , TBOnMinCnt
lds r20 , TBOffHourCnt
lds r21 , TBOffMinCnt
lds r16 , TAOnHourCnt
lds r17 , TAOnMinCnt
lds r22 , TAOffHourCnt
lds r23 , TAOffMinCnt
rjmp CheckInlaid
TimerDispLogic90:
ret
;-------------------------------------------------
;input:wait timer time
;r16:TOnHourCnt r17:TOnMinCnt
;r22:TOffHourCnt r23:TOffMinCnt
;input:now run timer time
;r18:TxOnHourCnt r19:TxOnMinCnt
;r20:TxOffHourCnt r21:TxOffMinCnt
;output:
;TimerDispHour TimerDispMin
CheckInlaid:
cp r18 , r20
brcs CheckInlaid50 ;r18<r20 on<off
brne CheckInlaid10 ;r18>r20 on>off
cp r19 , r21
brcs CheckInlaid50 ;r18=r20 r19<r21 on<off
CheckInlaid10:
;----now on>off----------
mov r26 , r16
mov r27 , r17
rcall CheckPutIn
sbrs SystemByte , TempBit0
sbrc SystemByte , TempBit1
rjmp CheckInlaid20
;-----wait timer on time not inlaid now timer time--
CheckInlaid15:
;will display now timer off time
sts TimerDispHour , r20
sts TimerDispMin , r21
rjmp CheckInlaid90
CheckInlaid20:
;-----wait timer on time in the now timer time
mov r26 , r22
mov r27 , r23
rcall CheckPutIn
sbrs SystemByte , TempBit0
sbrc SystemByte , TempBit1
rjmp CheckInlaid15 ;wait timer off time in the now timer time
;-----wait timer off time not inlaid now timer time--
CheckInlaid25:
;will display wait timer off time
sts TimerDispHour , r22
sts TimerDispMin , r23
rjmp CheckInlaid90
CheckInlaid50:
;----on<off----------
mov r26 , r16
mov r27 , r17
rcall CheckPutIn
sbrc SystemByte , TempBit0
sbrs SystemByte , TempBit1
rjmp CheckInlaid15 ;wait timer on time not inlaid now timer time
;---wait timer on time in the now timer time
mov r26 , r22
mov r27 , r23
rcall CheckPutIn
sbrc SystemByte , TempBit0
sbrs SystemByte , TempBit1
rjmp CheckInlaid25 ;wait timer off time not in the now timer time
rjmp CheckInlaid15
CheckInlaid90:
ret
CheckPutIn:
;--input: check time:r26:hour r27:min
;--ouput: if checktime>timer on then TempBit0=1
; if checktime<timer off then TempBit1=1
clt
bld SystemByte, TempBit0
bld SystemByte, TempBit1
cp r18 , r26
brcs CheckPutIn30 ;r18<r26 on<test
brne CheckPutIn10 ;r18>r26 on>test
cp r19 , r27
brcs CheckPutIn30 ;r18=r26 r19<r27 on<test
CheckPutin10:
;----now on>test time----------
rjmp CheckPutIn50
CheckPutIn30:
set
bld SystemByte , TempBit0
CheckPutIn50:
cp r20 , r26
brcs CheckPutIn80 ;r20<r26 off<test
brne CheckPutIn60 ;r20>r26 off>test
cp r21 , r27
brcs CheckPutIn80 ;r20=r26 r21<r27 off<test
CheckPutin60:
;----now off>test time----------
set
bld SystemByte , TempBit1
CheckPutIn80:
ret
;-------------------------------------------------
Timerjudge:
clt
cp Reg1 , Reg3
brne Timerjudge10
cp Reg0 , Reg2
breq Timerjudge90
Timerjudge10:
cp Reg1 , Reg3
cpc Reg0 , Reg2
brcs Timerjudge50
;-----timer on > timer off
set
lds r16 , TimeHourCnt
lds r17 , TimeMinCnt
cp r17 , Reg1 ;timer on
cpc r16 , Reg0
brcc Timerjudge90
cp r17 , Reg3 ;timer off
cpc r16 , Reg2
brcs Timerjudge90
;------ time off <=real time <time on then off---
clt
rjmp Timerjudge90
Timerjudge50:
lds r16 , TimeHourCnt
lds r17 , TimeMinCnt
cp r17 , Reg3
cpc r16 , Reg2
brcc Timerjudge90
cp r17 , Reg1
cpc r16 , Reg0
brcs Timerjudge90
;------ time oN <=real time <time off then on---
set
Timerjudge90:
bld SystemByte , TempBit0
ret
;-------------------------------------------------
Logic:
sts BuffSetByte ,SetByte
sts BuffModeByte,ModeByte
lds r16 , SetTemp
sts BuffSetTemp , r16
rcall CheckSum
sts CheckSumLow , Reg0
sts CheckSumHigh , Reg1
tst ErrorByte
brne Logic05
sbrc SetByte , SetOnOff
rjmp Logic20
clr RunByte
Logic05:
clr AskByte
Logic06:
ret
Logic20:
lds r16,setdelay
tst r16
brne logic06 ;在设置状态时不进入
set
bld AskByte , NAsk
sbrc SetByte , SetNow
rjmp Logic29
clt
bld RunByte , TARun
bld RunByte , TBRun
sbrs SetByte , SetTimerA
rjmp Logic22
lds Reg0 , TAOnHourCnt
lds Reg1 , TAOnMinCnt
lds Reg2 , TAOffHourCnt
lds Reg3 , TAOffMinCnt
rcall TimerJudge
bst SystemByte , TempBit0
bld RunByte , TARun
Logic22:
sbrs SetByte , SetTimerB
rjmp Logic24
lds Reg0 , TBOnHourCnt
lds Reg1 , TBOnMinCnt
lds Reg2 , TBOffHourCnt
lds Reg3 , TBOffMinCnt
rcall TimerJudge
bst SysTemByte , TempBit0
bld RunByte , TBRun
Logic24:
sbrc SetByte , SetTimerA
rjmp Logic25
sbrs SetByte , SetTimerB
rjmp Logic29 ;------if no timer set------
Logic25:
sbrs RunByte , TARun
sbrc RunByte , TBRun
rjmp Logic29
clt
bld AskByte , NAsk
bld AskByte , HeaterAsk
bld RunByte , HeatRun
bld RunByte , KeepRun
rjmp Logic60
Logic29:
lds r16, Settempdefault
sbrs setbyte,setSTS
lds r16 , SetTemp
lds r17 , WaterTemp
subi r16 , 5
cp r16 , r17
brcs Logic30
;SetTemp-5>UpTemp
set
bld AskByte , HeaterAsk
rjmp Logic35
Logic30:
lds r16, Settempdefault
sbrs setbyte,setSTS
lds r16 , SetTemp
cp r17 , r16
brcs Logic35
clt
bld AskByte , heaterAsk
bld SetByte , SetNow
Logic35:
sbrs SetByte , SetNow
rjmp logic36
set
bld askbyte,heaterask
bld RunByte , HeatRun
rjmp logic90
Logic36:
clt
bld RunByte , HeatRun
bld RunByte , KeepRun
set
sbrc AskByte , HeaterAsk
bld RunByte , HeatRun
sbrs AskByte , HeaterAsk
bld RunByte , KeepRun
Logic60:
Logic90:
ret
;================================================
ErrorLogic:
ldi r16 , 5
ErrorLogic01:
sbic LeakPort , LeakLine
rjmp ErrorLogic05
rcall delay10us
dec r16
brne ErrorLogic01
lds r16 , LeakLineCnt
dec r16
sts LeakLineCnt , r16
breq ErrorLogic02
rjmp ErrorLogic06
ErrorLogic02:
set
bld ErrorByte , LeakErr
ErrorLogic05:
ldi r16 , LeakLineInit
STS LeakLineCnt , r16
ErrorLogic06:
lds r16 , WaterTemp
cpi r16 , 83
brcs ErrorLogic15
set
bld ErrorByte , HeaterErr
ErrorLogic15:
lds r16 , WaterTemp
cpi r16 , 88
brcs ErrorLogic16
set
bld ErrorByte , HeaterErrH
ErrorLogic16:
tst errorbyte
brne errorlogic90
sbrs UserTrigger , TempTrigger
rjmp ErrorLogic50
clt
bld UserTrigger , TempTrigger
lds r17 , TempSP
inc r17
sts TempSP , r17
lds r17 , TempRem0
lds r16 , WaterTemp
sub r16,r17
brcs ErrorLogic20
cpi r16 , 10
brcs ErrorLogic20
lds r16 , WaterTemp
cpi r16 , 50
brcs ErrorLogic20
lds r16 , EmptyDelay
dec r16
sts EmptyDelay , r16
brne ErrorLogic25
set
bld ErrorByte , EmptyErr
ErrorLogic20:
ldi r16 , 5
sts EmptyDelay , r16
ErrorLogic25:
lds r16 , TempSP
cpi r16 , 12
brcs ErrorLogic50
clr r16
sts TempSP , r16
lds r16 , TempRem1
sts TempRem0 , r16
lds r16 , TempRem2
sts TempRem1 , r16
lds r16 , WaterTemp
sts TempRem2 , r16
ErrorLogic50:
ErrorLogic90:
ret
;--------------------------------------------
;-------------------------------------------
NumberDisp:
;input:r16 , output:r17r16
clr r17
tst r16
breq NumberDisp50
;------------Hex To Dec ----
NumberDisp10:
subi r16 , $a
brcs NumberDisp20
inc r17
rjmp NumberDisp10
NumberDisp20:
ldi r30 , $a
add r16 , r30
;---------------------------
NumberDisp50:
ldi r31 , high(NumberTab*2)
ldi r30 , low(NumberTab*2)
add r30 , r16
brcc NumberDisp60
inc r31
NumberDisp60:
lpm r16 , Z
ldi r30 , low(NumberTab*2)
add r30 , r17
brcc NumberDisp70
inc r31
NumberDisp70:
lpm r17 , Z
ret
;-------------------------------------------
Display:
sbrs UserTrigger , DispTrigger ;位DispTrigger为1跳行
ret ;返回
clt ;清零T
bld UserTrigger , DispTrigger ;T送DispTrigger位
ser r18 ;data1 ;r18全置1(下同)
ser r19 ;data2
ser r20 ;data3
ser r21 ;data4
ser r22 ;data5
ser r23 ;data6
tst ErrorByte ;测试ErrorByte是否为0
breq Display08 ;Z=1转移到Display08
cbr r23 , (1<<LEDMark) ;r23清零
sbrs ErrorByte , HeaterErrH ;如HeaterErrH位为1则跳行
sbrc BlinkByte0 , Blink250ms ;如Blink250ms位为0则跳行
rjmp Blink250ms ;跳到
ldi r22 , 69 ;'E' ;把69装入r22
ldi r21 , 250 ;'1' ;把250装入r22
sbrc ErrorByte , EmptyErr; ;如EmptyErr位为0则跳行
rjmp Display90 ;跳到标号Display90处
ldi r21 , 76 ;'2' ;把76装入r21
sbrc ErrorByte , WaterSenErr ;如WaterSenErr位为0则行
rjmp Display90 ;跳到标号Display90处
ldi r21 , 74 ;'3' ;把74装入r21
sbrc ErrorByte , LeakErr ;如LeakErr位为0则跳行
rjmp Display90 ;跳到标号Display90处
ldi r21 , 226 ;'4' ;把226装入r21
sbrc ErrorByte , HeaterErr ;如HeaterErr位为0则跳行
rjmp Display90 ;跳到标号Display90处
Display08: ;
sbrs SetByte , SetOnOff ;如SetOnOff位为1则跳行
rjmp Display90 ;跳到标号Display90处
cbr r23 , (1<<LEDMark) ;r23清零
sbrs setbyte,setsts ;如setsts位为1则跳行
rjmp display15 ;跳到标号display15处
lds r16,settempdefault ;从settempdefault单元中取数给r16
cpi r16,60 ;r16中数与60比较
brne display10 ;不相等则转移到display10
cbr r23 ,(1<<LEDLow) ;
display10:
cpi r16,50 ;
brne display11 ;
cbr r18 , (1<<LEDMid) ;
display11:
cpi r16,70 ;
brne display15 ;
cbr r18 ,(1<<LEDHigh) ;
Display15:
sbrc SetByte , SetNow ;
rjmp display15_0 ;
sbrc RunByte , KeepRun ;
cbr r18 , (1<<LEDKeep)
sbrc RunByte , HeatRun
display15_0:
cbr r22 , (1<<LEDHeater)
lds r16 , SetSP
tst r16
breq Display16
rjmp Display30
;-------No set --------
Display16:
lds r16 , TimerDispDelay
tst r16
breq Display17
;------if timer time display query----
cbr r20 , (1<<LEDDot1)
cbr r21 , (1<<LEDDot2)
lds r16 , TimerDispHour
rcall NumberDisp
and r21 , r16
and r22 , r17
lds r16 , TimerDispMin
rcall NumberDisp
and r19 , r16
and r20 , r17
rjmp Display20
Display17:
sbrs UserTrigger ,display8s
rjmp Display18_0
clt
bld UseRTrigger,display8s
rjmp Display18
Display17_1:
sbrc setbyte,setnow
rjmp display18
ldi r16 , 0b00001100
and r16 , SetByte
cpi r16 , 0b00001100
breq display17_00
rjmp display17_5
display17_00:
wdr
sts temp_r18,r18
sts temp_r19,r19
sts temp_r20,r20
sts temp_r21,r21
sts temp_r22,r22
sts temp_r23,r23
lds Reg4 , TimeHourCnt
lds Reg5 , TimeMinCnt
lds r16 , TAOnHourCnt
lds r17 , TAOnMinCnt
rcall caculator
sts disptaOnMin ,r17
sts disptaonhour ,r16
;=====================================
lds Reg4 , TimeHourCnt
lds Reg5 , TimeMinCnt
lds r16 , TAOffHourCnt
lds r17 , TAOffMinCnt
rcall caculator
sts disptaOffMin ,r17
sts disptaoffhour ,r16
;======================================
lds Reg4 , TimeHourCnt
lds Reg5 , TimeMinCnt
lds r16 , TBOnHourCnt
lds r17 , TBOnMinCnt
rcall caculator
sts disptBOnMin ,r17
sts disptBonhour ,r16
;========================================
lds Reg4 , TimeHourCnt
lds Reg5 , TimeMinCnt
lds r16 , TBOffHourCnt
lds r17 , TBOffMinCnt
rcall caculator
sts disptBOffMin ,r17
sts disptBoffhour ,r16
;========================================
lds r16 , disptaonHour
lds r17 , disptaonMin
lds r18 , disptaoffHour
lds r19 , disptaoffMin
lds r20 , disptbonHour
lds r21 , disptbonMin
lds r22 , disptboffHour
lds r23 , disptboffMin
clt
bld UserTrigger,disptaon
bld UserTrigger,disptbon
bld SystemByte, disptaoff
bld setbyte, disptboff
set
cp r17 , r19
cpc r16 , r18
brcc display17_7
cp r17 , r21
cpc r16 , r20
brcc display17_8
cp r17 , r23
cpc r16 , r22
brcc display17_10 ; 显示TB关闭的时间
bld UserTrigger,disptaon
rjmp display17_11 ; 显示TA开启的时间
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -