📄 lcd1602.s
字号:
subi R24,255 ; addi 1
sts _month,R24
.dbline 282
; day=0;
clr R2
sts _day,R2
.dbline 283
; }
xjmp L124
L123:
.dbline 284
; else if((month<=7)&&(month%2==0)&&(day==31))//其他月份小于等于7月份的偶数月份是30天
ldi R24,7
lds R2,_month
cp R24,R2
brlo L125
ldi R17,2
mov R16,R2
xcall mod8u
tst R16
brne L125
lds R24,_day
cpi R24,31
brne L125
.dbline 285
; {
.dbline 286
; month++;
lds R24,_month
subi R24,255 ; addi 1
sts _month,R24
.dbline 287
; day=0;
clr R2
sts _day,R2
.dbline 288
; }
xjmp L126
L125:
.dbline 289
; else if((month<=7)&&(month%2!=0)&&(day==32))//奇数是31天;
ldi R24,7
lds R2,_month
cp R24,R2
brlo L127
ldi R17,2
mov R16,R2
xcall mod8u
tst R16
breq L127
lds R24,_day
cpi R24,32
brne L127
.dbline 290
; {
.dbline 291
; month++;
lds R24,_month
subi R24,255 ; addi 1
sts _month,R24
.dbline 292
; day=0;
clr R2
sts _day,R2
.dbline 293
; }
xjmp L128
L127:
.dbline 294
; else if((month>7)&&(month%2==0)&&(day==32))//大于7月份的偶数月份是31天
ldi R24,7
lds R2,_month
cp R24,R2
brsh L129
ldi R17,2
mov R16,R2
xcall mod8u
tst R16
brne L129
lds R24,_day
cpi R24,32
brne L129
.dbline 295
; {
.dbline 296
; month++;
lds R24,_month
subi R24,255 ; addi 1
sts _month,R24
.dbline 297
; day=0;
clr R2
sts _day,R2
.dbline 298
; }
xjmp L130
L129:
.dbline 299
; else if((month>7)&&(month%2!=0)&&(day==31))//奇数是30天;
ldi R24,7
lds R2,_month
cp R24,R2
brsh L131
ldi R17,2
mov R16,R2
xcall mod8u
tst R16
breq L131
lds R24,_day
cpi R24,31
brne L131
.dbline 300
; {
.dbline 301
; month++;
lds R24,_month
subi R24,255 ; addi 1
sts _month,R24
.dbline 302
; day=0;
clr R2
sts _day,R2
.dbline 303
; }
L131:
L130:
L128:
L126:
L124:
L110:
.dbline 304
; if(month==13)
lds R24,_month
cpi R24,13
brne L133
.dbline 305
; {
.dbline 306
; year++;
lds R24,_year
lds R25,_year+1
adiw R24,1
sts _year+1,R25
sts _year,R24
.dbline 307
; month=0;
clr R2
sts _month,R2
.dbline 308
; }
L133:
.dbline 310
;
; }
L101:
.dbline 313
;
;
; TCNT1H = 0xC2; //reload counter high value
ldi R24,194
out 0x2d,R24
.dbline 314
; TCNT1L = 0xF7; //reload counter low value
ldi R24,247
out 0x2c,R24
.dbline 315
; WDR();
wdr
.dbline -2
L100:
ld R2,y+
out 0x3f,R2
ld R25,y+
ld R24,y+
ld R19,y+
ld R18,y+
ld R17,y+
ld R16,y+
ld R2,y+
.dbline 0 ; func end
reti
.dbend
.area vector(rom, abs)
.org 4
jmp _int0_isr
.area text(rom, con, rel)
.dbfile D:\练习\LCD显示1602\lcd1602.c
.dbfunc e int0_isr _int0_isr fV
.even
_int0_isr::
xcall push_lset
.dbline -1
.dbline 321
; }
; //******************************************************************
; //每按一次时间设定键,其值加1,在正常情况下为0,每加1代表要修改的位置变化一次;
; #pragma interrupt_handler int0_isr:2
; void int0_isr(void)
; {
.dbline 323
; //external interupt on INT0
; WDR();
wdr
.dbline 324
; GICR=0X40; //清除INT0中断,延时20MS判断是否为干扰;
ldi R24,64
out 0x3b,R24
.dbline 325
; delay_ms(20);
ldi R16,20
ldi R17,0
xcall _delay_ms
.dbline 326
; if((PIND&0x04)==0x00)
sbic 0x10,2
rjmp L141
.dbline 327
; {
.dbline 328
; time_set++; //不是干扰,加1
lds R24,_time_set
subi R24,255 ; addi 1
sts _time_set,R24
.dbline 329
; if(time_set==7)//超过6次就返回正常状态;
cpi R24,7
brne L141
.dbline 330
; {
.dbline 331
; time_set=0;
clr R2
sts _time_set,R2
.dbline 332
; }
.dbline 333
; }
xjmp L141
L140:
.dbline 335
.dbline 336
wdr
.dbline 337
L141:
.dbline 334
; while((PIND&0x04)==0x00)//判断按键是否释放;
sbis 0x10,2
rjmp L140
.dbline 338
; {
; WDR(); //一定要在判断按键释放循环中喂狗;
; }
; GICR=0XC0;//恢复中断INT0
ldi R24,192
out 0x3b,R24
.dbline -2
L135:
xcall pop_lset
.dbline 0 ; func end
reti
.dbend
.area vector(rom, abs)
.org 8
jmp _int1_isr
.area text(rom, con, rel)
.dbfile D:\练习\LCD显示1602\lcd1602.c
.dbfunc e int1_isr _int1_isr fV
.even
_int1_isr::
xcall push_lset
xcall push_gset1
.dbline -1
.dbline 344
; }
; //******************************************************************
; //当time_set在某位时,单击此按键加一;
; #pragma interrupt_handler int1_isr:3
; void int1_isr(void)
; {
.dbline 346
; //external interupt on INT1
; WDR();
wdr
.dbline 347
; GICR=0X80;
ldi R24,128
out 0x3b,R24
.dbline 348
; delay_ms(20);
ldi R16,20
ldi R17,0
xcall _delay_ms
.dbline 349
; if((PIND&0x08)==0x00)
sbic 0x10,3
rjmp L188
.dbline 350
; {
.dbline 351
; switch(time_set)//判断是哪个位要改变数值;
lds R20,_time_set
clr R21
cpi R20,1
ldi R30,0
cpc R21,R30
breq L149
cpi R20,2
ldi R30,0
cpc R21,R30
breq L152
cpi R20,3
ldi R30,0
cpc R21,R30
breq L155
cpi R20,4
ldi R30,0
cpc R21,R30
brne X15
xjmp L158
X15:
cpi R20,5
ldi R30,0
cpc R21,R30
brne X16
xjmp L183
X16:
cpi R20,6
ldi R30,0
cpc R21,R30
brne X17
xjmp L186
X17:
xjmp L188
X11:
.dbline 352
; {
L149:
.dbline 354
; case 1:
; {
.dbline 355
; sec++;
lds R24,_sec
subi R24,255 ; addi 1
sts _sec,R24
.dbline 356
; if(sec==60)
cpi R24,60
breq X18
xjmp L188
X18:
.dbline 357
; {
.dbline 358
; sec=0;
clr R2
sts _sec,R2
.dbline 359
; }
.dbline 360
; break;//一定要用 break跳出;
xjmp L188
L152:
.dbline 363
; }
; case 2:
; {
.dbline 364
; min++;
lds R24,_min
subi R24,255 ; addi 1
sts _min,R24
.dbline 365
; if(min==60) //超过60分,清0
cpi R24,60
breq X19
xjmp L188
X19:
.dbline 366
; {
.dbline 367
; min=0;
clr R2
sts _min,R2
.dbline 368
; }
.dbline 369
; break;
xjmp L188
L155:
.dbline 372
; }
; case 3:
; {
.dbline 373
; hou++;
lds R24,_hou
subi R24,255 ; addi 1
sts _hou,R24
.dbline 374
; if(hou==24)
cpi R24,24
breq X20
xjmp L188
X20:
.dbline 375
; {
.dbline 376
; hou=0;
clr R2
sts _hou,R2
.dbline 377
; }
.dbline 378
; break;
xjmp L188
L158:
.dbline 381
; }
; case 4:
; {
.dbline 382
; day++;
lds R24,_day
subi R24,255 ; addi 1
sts _day,R24
.dbline 383
; if(((year%4==0)&&(year%100!=0))||(year%400==0)) //判断是否为闰年 1为闰年
lds R24,_year
lds R25,_year+1
andi R24,3
andi R25,0
cpi R24,0
cpc R24,R25
brne L162
X12:
ldi R18,100
ldi R19,0
lds R16,_year
lds R17,_year+1
xcall mod16u
cpi R16,0
cpc R16,R17
brne L161
X13:
L162:
ldi R18,400
ldi R19,1
lds R16,_year
lds R17,_year+1
xcall mod16u
cpi R16,0
cpc R16,R17
breq X21
xjmp L159
X21:
X14:
L161:
.dbline 384
; {
.dbline 385
; if((month==2)&&(day==30))//闰年2月份是29天
lds R24,_month
cpi R24,2
brne L163
lds R24,_day
cpi R24,30
brne L163
.dbline 386
; {
.dbline 388
; //month++;
; day=0;
clr R2
sts _day,R2
.dbline 389
; }
xjmp L188
L163:
.dbline 390
; else if((month<=7)&&(month%2==0)&&(day==31))//其他月份小于等于7月份的偶数月份是30天
ldi R24,7
lds R2,_month
cp R24,R2
brlo L165
ldi R17,2
mov R16,R2
xcall mod8u
tst R16
brne L165
lds R24,_day
cpi R24,31
brne L165
.dbline 391
; {
.dbline 393
; //month++;
; day=0;
clr R2
sts _day,R2
.dbline 394
; }
xjmp L188
L165:
.dbline 395
; else if((month<=7)&&(month%2!=0)&&(day==32))//奇数是31天;
ldi R24,7
lds R2,_month
cp R24,R2
brlo L167
ldi R17,2
mov R16,R2
xcall mod8u
tst R16
breq L167
lds R24,_day
cpi R24,32
brne L167
.dbline 396
; {
.dbline 398
; //month++;
; day=0;
clr R2
sts _day,R2
.dbline 399
; }
xjmp L188
L167:
.dbline 400
; else if((month>7)&&(month%2==0)&&(day==32))//大于7月份的偶数月份是31天
ldi R24,7
lds R2,_month
cp R24,R2
brsh L169
ldi R17,2
mov R16,R2
xcall mod8u
tst R16
brne L169
lds R24,_day
cpi R24,32
brne L169
.dbline 401
; {
.dbline 403
; //month++;
; day=0;
clr R2
sts _day,R2
.dbline 404
; }
xjmp L188
L169:
.dbline 405
; else if((month>7)&&(month%2!=0)&&(day==31))//奇数是30天;
ldi R24,7
lds R2,_month
cp R24,R2
brlo X22
xjmp L188
X22:
ldi R17,2
mov R16,R2
xcall mod8u
tst R16
brne X23
xjmp L188
X23:
lds R24,_day
cpi R24,31
breq X24
xjmp L188
X24:
.dbline 406
; {
.dbline 408
; //month++;
; day=0;
clr R2
sts _day,R2
.dbline 409
; }
.dbline 410
; }
xjmp L188
L159:
.dbline 411
; else if((month==2)&&(day==29))//不是闰年二月份是28天;
lds R24,_month
cpi R24,2
brne L173
lds R24,_day
cpi R24,29
brne L173
.dbline 412
; {
.dbline 414
; //month++;
; day=0;
clr R2
sts _day,R2
.dbline 415
; }
xjmp L188
L173:
.dbline 416
; else if((month<=7)&&(month%2==0)&&(day==31))//其他月份小于等于7月份的偶数月份是30天
ldi R24,7
lds R2,_month
cp R24,R2
brlo L175
ldi R17,2
mov R16,R2
xcall mod8u
tst R16
brne L175
lds R24,_day
cpi R24,31
brne L175
.dbline 417
; {
.dbline 419
; // month++;
; day=0;
clr R2
sts _day,R2
.dbline 420
; }
xjmp L188
L175:
.dbline 421
; else if((month<=7)&&(month%2!=0)&&(day==32))//奇数是31天;
ldi R24,7
lds R2,_month
cp R24,R2
brlo L177
ldi R17,2
mov R16,R2
xcall mod8u
tst R16
breq L177
lds R24,_day
cpi R24,32
brne L177
.dbline 422
; {
.dbline 424
; //month++;
; day=0;
clr R2
sts _day,R2
.dbline 425
; }
xjmp L188
L177:
.dbline 426
; else if((month>7)&&(month%2==0)&&(day==32))//大于7月份的偶数月份是31天
ldi R24,7
lds R2,_month
cp R24,R2
brsh L179
ldi R17,2
mov R16,R2
xcall mod8u
tst R16
brne L179
lds R24,_day
cpi R24,32
brne L179
.dbline 427
; {
.dbline 429
; // month++;
; day=0;
clr R2
sts _day,R2
.dbline 430
; }
xjmp L188
L179:
.dbline 431
; else if((month>7)&&(month%2!=0)&&(day==31))//奇数是30天;
ldi R24,7
lds R2,_month
cp R24,R2
brsh L188
ldi R17,2
mov R16,R2
xcall mod8u
tst R16
breq L188
lds R24,_day
cpi R24,31
brne L188
.dbline 432
; {
.dbline 434
; //month++;
; day=0;
clr R2
sts _day,R2
.dbline 435
; }
.dbline 436
; break;
xjmp L188
L183:
.dbline 439
; }
; case 5:
; {
.dbline 440
; month++;
lds R24,_month
subi R24,255 ; addi 1
sts _month,R24
.dbline 441
; if(month==13)
cpi R24,13
brne L188
.dbline 442
; {
.dbline 443
; month=0;
clr R2
sts _month,R2
.dbline 444
; }
.dbline 445
; break;
xjmp L188
L186:
.dbline 447
; }
; case 6: year++;break;
lds R24,_year
lds R25,_year+1
adiw R24,1
sts _year+1,R25
sts _year,R24
.dbline 447
.dbline 450
; }
;
; }
xjmp L188
L187:
.dbline 452
.dbline 453
wdr
.dbline 454
L188:
.dbline 451
; while((PIND&0x08)==0x00)
sbis 0x10,3
rjmp L187
.dbline 455
; {
; WDR();
; }
; GICR=0XC0;
ldi R24,192
out 0x3b,R24
.dbline -2
L143:
xcall pop_gset1
xcall pop_lset
.dbline 0 ; func end
reti
.dbend
.area bss(ram, con, rel)
.dbfile D:\练习\LCD显示1602\lcd1602.c
_Day::
.blkb 2
.dbsym e Day _Day A[2:2]c
_Month::
.blkb 2
.dbsym e Month _Month A[2:2]c
_Year::
.blkb 4
.dbsym e Year _Year A[4:4]c
_hour::
.blkb 2
.dbsym e hour _hour A[2:2]c
_minute::
.blkb 2
.dbsym e minute _minute A[2:2]c
_second::
.blkb 2
.dbsym e second _second A[2:2]c
.area data(ram, con, rel)
.dbfile D:\练习\LCD显示1602\lcd1602.c
L99:
.blkb 5
.area idata
.byte 32,32,32,32,0
.area data(ram, con, rel)
.dbfile D:\练习\LCD显示1602\lcd1602.c
L68:
.blkb 2
.area idata
.byte 32,0
.area data(ram, con, rel)
.dbfile D:\练习\LCD显示1602\lcd1602.c
L65:
.blkb 3
.area idata
.byte 32,32,0
.area data(ram, con, rel)
.dbfile D:\练习\LCD显示1602\lcd1602.c
L55:
.blkb 2
.area idata
.byte 58,0
.area data(ram, con, rel)
.dbfile D:\练习\LCD显示1602\lcd1602.c
L54:
.blkb 17
.area idata
.byte 'T,'i,'m,'e,58,32,32,32,32,32,32,32,32,32,32,32
.byte 0
.area data(ram, con, rel)
.dbfile D:\练习\LCD显示1602\lcd1602.c
L53:
.blkb 6
.area idata
.byte 'D,'a,'t,'e,58,0
.area data(ram, con, rel)
.dbfile D:\练习\LCD显示1602\lcd1602.c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -