📄 set_time.asm
字号:
ret
lcdoff:
ldi zh,high(lcdsram2+4)
ldi zl,low(lcdsram2+4)
mov tempd,keytab3
cpi tempd,$02
brsh lcdoff00
lcdoff0_0:
mov tempc,keytab4
cpi tempc,$02
brlo lcdoff0_1
adiw zl,$01
cpi tempc,$04
brlo lcdoff0_1
adiw zl,$01
cpi tempc,$06
brlo lcdoff0_1
adiw zl,$01
lcdoff0_1:
add zl,tempc
adc zh,clrtemp
ldi tempc,$20
st z,tempc
ret
lcdoff00:
ldi zh,high(lcdsram2)
ldi zl,low(lcdsram2)
ldi tempc,$20
ldi tempd,16
lcdoff10_0:
st z+,tempc
dec tempd
brne lcdoff10_0
ret
movlcd0:
mov tempc,buffbit
sbr buffbit,bit_1
sbrc tempc,bit1
cbr buffbit,bit_1
sbrc buffbit,bit1
rjmp movlcdon0
ldi zh,high(lcdsram2)
ldi zl,low(lcdsram2)
mov tempc,keytab4
cpi tempc,$04
brlo lcdoff0_0
adiw zl,5
rjmp lcdoff0_0
;**************************************************
sendwrite:
rcall sendst
ldi tempc,$00
sts udr0,tempc
wsend1:
lds tempc,ucsr0a
sbrs tempc,udre0
rjmp wsend1
ldi yh,high(timesram)
ldi yl,low(timesram)
ldi tempe,21
clr tempb
wsend3:
wdr
ld tempd,y+
sts udr0,tempd
add tempb,tempd
wsend4:
lds tempc,ucsr0a
sbrs tempc,udre0
rjmp wsend4
dec tempe
brne wsend3
sts udr0,tempd
wsend5:
lds tempc,ucsr0a
sbrs tempc,udre0
rjmp wsend5
ret
;**************************************************
sendread:
rcall sendst
ldi tempc,$01
sts udr0,tempc
rsend1:
lds tempc,ucsr0a
sbrs tempc,udre0
rjmp rsend1
rsend2:
ldi tempd,$cc
ldi tempe,$08
clr tempb
rsend3:
wdr
sts udr0,tempd
add tempb,tempd
rsend4:
lds tempc,ucsr0a
sbrs tempc,udre0
rjmp rsend4
dec tempe
brne rsend3
sts udr0,tempd
rsend5:
lds tempc,ucsr0a
sbrs tempc,udre0
rjmp rsend5
ret
;**************************************************
sendst:
sbi portd,pd2
lds tempc,ucsr0b
cbr tempc,bit_0;txb80
sbr tempc,bit_3;txen0
sts ucsr0b,tempc
ldi tempc,$aa
sts udr0,tempc
sendst0:
lds tempd,ucsr0a
sbrs tempd,udre0
rjmp sendst0
lds tempc,ucsr0b
sbr tempc,bit_0 ;txb80
sts ucsr0b,tempc
ret
;**************************************************
Send_Byte:
sbi ddrb,sdi
cbi portb,rst
cbi portb,sck
ldi tempd,$08 ;BitCnt传送位数为8
sbi portb,rst ;复位引脚为高电平逻辑控制有效
nop
nop
nop
nop
nop
nop
lds tempc,command
S_Byte0:
sbi portb,sdi
sbrs tempc,bit0
cbi portb,sdi
lsr tempc ;Command,f
sbi portb,sck ;时钟上升沿 发送数据有效
nop
nop
nop
nop
nop
nop
cbi portb,sck ;清时钟总线
nop
dec tempd ;BitCnt
brne S_Byte0 ;位传送未完毕则继续
S_Byte1: ;准备发送数据
ld tempc,z+
ldi tempd,$08
S_Byte2:
sbi portb,sdi
sbrs tempc,bit0
cbi portb,sdi
lsr tempc ;Command
sbi portb,sck
nop
nop
nop
nop
nop
nop
cbi portb,sck
nop
nop
dec tempd
brne S_Byte2
; dec tempf
; brne S_Byte1 ;ByteCnt;字节传送未完毕则继续
cbi portb,rst ;逻辑操作完毕 清 RST
ret
;**************************************************
Receive_Byte:
sbi ddrb,sdi
cbi portb,sck
cbi portb,rst
ldi tempd,$08
sbi portb,rst
nop
nop
nop
nop
nop
nop
lds tempc,command
R_Byte0:
sbi portb,sdi
sbrs tempc,bit0
cbi portb,sdi
lsr tempc
nop
nop
sbi portb,sck
nop
nop
nop
nop
nop
nop
cbi portb,sck
nop
nop
dec tempd
brne R_Byte0
nop
nop
nop
nop
sbi portb,sdi
cbi ddrb,sdi
R_Byte1:
clr tempc
ldi tempd,$08
R_Byte2:
in tempb,pinb
nop
nop
sbi portb,sck
bst tempb,sdi
lsr tempc
bld tempc,bit7
nop
nop
nop
cbi portb,sck ;时钟下降沿接收数据有效
nop
nop
nop
dec tempd
brne R_Byte2 ;位接收未完毕则继续
st z+,tempc
dec tempf
brne R_Byte1 ;字节接收未完毕则继续
nop
nop
cbi portb,rst ;逻辑操作完毕 清 RST
ret
;**************************************************
kdisp000:
ldi zh,high(lcdtab000*2)
ldi zl,low(lcdtab000*2)
movlcd00:
ldi tempd,16
sbr keybit,bit_4
movlcd02:
ldi yh,high(lcdsram1)
ldi yl,low(lcdsram1)
movlcd01:
lpm tempc,z+
st y+,tempc
dec tempd
brne movlcd01
ret
;**************************************************
kdisp001:
ldi zh,high(lcdtab001*2)
ldi zl,low(lcdtab001*2)
ldi tempc,$10
mul tempc,keytab1
movlcd10:
add zl,r0
adc zh,r1
ldi tempd,16
sbr keybit,bit_5
ldi yh,high(lcdsram2)
ldi yl,low(lcdsram2)
rjmp movlcd01
;**************************************************
kdisp100:
ldi zh,high(lcdtab110*2)
ldi zl,low(lcdtab110*2)
rjmp movlcd00
kdisp101:
ldi zh,high(lcdtab111*2)
ldi zl,low(lcdtab111*2)
ldi tempc,$10
mul tempc,keytab2
rjmp movlcd10
;**************************************************
kdisp200:
ldi zh,high(lcdtab200*2)
ldi zl,low(lcdtab200*2)
rjmp movlcd00
kdisp201:
ldi zh,high(lcdtab201*2)
ldi zl,low(lcdtab201*2)
ldi tempc,$10
mul tempc,keytab3
rjmp movlcd10
;**************************************************
kdisp210:
ldi zh,high(lcdtab210*2)
ldi zl,low(lcdtab210*2)
rjmp movlcd00
kdisp211:
ldi zh,high(lcdtab211*2)
ldi zl,low(lcdtab211*2)
ldi tempc,$10
mul tempc,keytab3
rjmp movlcd10
;**************************************************
kdisp300:
ldi zh,high(lcdtab300*2)
ldi zl,low(lcdtab300*2)
rjmp lcdmov32str
kdisp1000:
ldi zh,high(lcdtab100*2)
ldi zl,low(lcdtab100*2)
rjmp lcdmov32str
kdisp1001:
ldi zh,high(lcdtab230*2)
ldi zl,low(lcdtab230*2)
rjmp lcdmov32str
kdisp1002:
ldi zh,high(lcdtab220*2)
ldi zl,low(lcdtab220*2)
rjmp lcdmov32str
kdisp1003:
ldi zh,high(lcdtab320*2)
ldi zl,low(lcdtab320*2)
rjmp lcdmov32str
kdisp1004:
ldi zh,high(lcdtab250*2)
ldi zl,low(lcdtab250*2)
rjmp lcdmov32str
kdisp1005:
ldi zh,high(lcdtab240*2)
ldi zl,low(lcdtab240*2)
lcdmov32str:
ldi tempd,32
sbr keybit,bit_5
rjmp movlcd02
;**************************************************
kdisp301:
ldi zh,high(lcdtab301*2)
ldi zl,low(lcdtab301*2)
rjmp lcdmov32str
;**************************************************
kdisp302:
ldi zh,high(lcdtab301*2)
ldi zl,low(lcdtab301*2)
rjmp movlcd00
kdisp303:
ldi zh,high(lcdtab302*2)
ldi zl,low(lcdtab302*2)
ldi tempc,$10
lds tempd,daysram
mul tempc,tempd
rjmp movlcd10
kdisp310:
ldi zh,high(lcdtab310*2)
ldi zl,low(lcdtab310*2)
rjmp lcdmov32str
kdisp3100:
mov tempc,keytab3
cpi tempc,$00
brne kdisp310_0
ldi yh,high(hr1sramh+1)
ldi yl,low(hr1sramh+1)
rjmp kdisp310_2
kdisp310_0:
cpi tempc,$01
brne kdisp310_1
ldi yh,high(hr2sramh+1)
ldi yl,low(hr2sramh+1)
rjmp kdisp310_2
kdisp310_1:
ldi yh,high(hr3sramh+1)
ldi yl,low(hr3sramh+1)
kdisp310_2:
ldi xh,high(lcdsram2)
ldi xl,low(lcdsram2)
ldi tempe,$01
rcall srammovlcd0
ldi tempe,$01
rcall srammovlcd0
ldi tempe,$01
adiw xl,5
ldi tempe,$01
rcall srammovlcd0
ldi tempe,$01
rcall srammovlcd0
ret
;**************************************************
sethrh:
mov tempd,tempc
andi tempd,$0f
andi tempc,$f0
ldi tempb,$10
add tempc,tempb
cpi tempc,$30
brlo timeh0_0
clr tempc
timeh0_0:
cpi tempc,$20
brlo timem0_0
cpi tempd,$04
brlo timem0_0
ldi tempd,$03
rjmp timem0_0
;**************************************************
sethrl:
mov tempd,tempc
andi tempd,$f0
andi tempc,$0f
inc tempc
cpi tempd,$20
brlo timeh1_0
cpi tempc,$04
brlo timem0_0
clr tempc
timeh1_0:
cpi tempc,$0a
brlo timem0_0
rjmp timem0_1
;**************************************************
setminh:
setsrch:
mov tempd,tempc
andi tempd,$0f
andi tempc,$f0
ldi tempb,$10
add tempc,tempb
cpi tempc,$60
brlo timem0_0
timem0_1:
clr tempc
timem0_0:
or tempc,tempd
ret
;**************************************************
setminl:
setsrcl:
mov tempd,tempc
andi tempd,$f0
andi tempc,$0f
inc tempc
cpi tempc,$0a
brlo timem0_0
rjmp timem0_1
;**************************************************
lcdtab0:
.db "0123456789"
;**************************************************
lcdtab000:
; 0123456789abcfef
.db " System Set "
lcdtab001:
.db "1:Display Time " ;keytab1
.db "2:Settings "
;**************************************************
lcdtab100: ;01234 0123
.db " 2007-01-01 "
.db " 00:00:00 "
;**************************************************
lcdtab110:
.db " Settings "
lcdtab111:
.db "1:Set Time&Date " ;keytab2
.db "2:Set ON Time "
.db "3:Set WriteTime "
.db "4:Set ReadTime "
;**************************************************
lcdtab200:
.db " Set Time&Date "
lcdtab201:
.db "1:Set Time " ;keytab3
.db "2:Set Date "
.db "3:Set Day "
lcdtab300:
.db " HH:MM:SS " ;keytab4
.db " 00:00:00 "
lcdtab301:
.db " YY-MM-DD " ;keytab4
.db " 07-01-01 "
lcdtab302:
.db " x-Day " ;keytab4
.db " 1-Monday " ;1
.db " 2-Tuesday " ;2
.db " 3-Wednesday " ;3
.db " 4-Thursday " ;4
.db " 5-Friday " ;5
.db " 6-Saturday " ;6
.db " 7-Sunday " ;7
;**************************************************
lcdtab210:
.db " Set ON Time "
lcdtab211:
.db "1:Time1(*) " ;keytab3
.db "2:Time2( ) "
.db "3:Time3( ) "
lcdtab310:
.db "HH:MM>Time>HH:MM" ;keytab4
.db "04:00>Time>19:00"
;**************************************************
lcdtab220:
.db " Set WriteTime " ;keytab4
.db " True Write ? "
lcdtab320:
.db " WriteTime "
.db " Writeing "
;**************************************************
lcdtab230:
.db " ReadTime "
.db " Reading "
;**************************************************
lcdtab240:
.db "R_YMD:2007-01-01"
.db "R_HMS: 00:00:00 "
;**************************************************
lcdtab250:
.db " ReadTime "
.db " ReadTime blank "
;**************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -