⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtc.s

📁 已经上传的YF-320240-3.5寸彩屏(可由单片机控制)的测试程序。主CPU为MEGA128
💻 S
字号:
	.module rtc.c
	.area text(rom, con, rel)
	.dbfile F:\Relations\sf6_system\measure\LCDtest\rtc.c
	.dbfunc e ReadTime _ReadTime fV
	.even
_ReadTime::
	.dbline -1
	.dbline 21
; #include <iom128v.h>
; #include "rtc.h"
; #include "lcd.h"
; #include <eeprom.h>
; 
; /***************************************************************
;  address     data
;  0           second
;  2           minutes
;  4           hour
;  8           month
;  9           year
;  A           register A
;  B           register B
;  C           register C
;  D           register D
;  E           2000year high byte
; ***************************************************************/
; struct Time time;
; void ReadTime(void)//时间是BCD码
; {   
L2:
	.dbline 22
L3:
	.dbline 22
; 	    while(REG_A & 0x80);
	lds R2,45066
	sbrc R2,7
	rjmp L2
	.dbline 23
; 	    time.second = SECOND;
	lds R2,45056
	sts _time,R2
	.dbline 24
; 		time.minute = MINUTE;
	lds R2,45058
	sts _time+1,R2
	.dbline 25
; 		time.hour   = HOUR;
	lds R2,45060
	sts _time+2,R2
	.dbline 26
; 		time.day    = DAY;
	lds R2,45063
	sts _time+3,R2
	.dbline 27
; 		time.month  = MONTH;
	lds R2,45064
	sts _time+4,R2
	.dbline 28
; 		time.year_L   = YEAR;
	lds R2,45065
	sts _time+5,R2
	.dbline 29
; 		time.year_H   = REG_E;
	lds R2,45070
	sts _time+6,R2
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e DisTime _DisTime fV
;           temp -> R10
;           back -> R14
;          front -> R12
;              y -> R22
;              x -> R20,R21
	.even
_DisTime::
	xcall push_gset5
	mov R22,R18
	movw R20,R16
	sbiw R28,6
	ldd R12,y+16
	ldd R14,y+18
	.dbline -1
	.dbline 32
; }
; void DisTime(unsigned int x,unsigned char y,unsigned char front,unsigned char back)
; {
	.dbline 34
;     unsigned char temp;
; 	ReadTime();
	xcall _ReadTime
	.dbline 35
; 	temp = time.hour>>4;//hour的十位数
	lds R24,_time+2
	swap R24
	andi R24,#0x0F
	.dbline 36
; 	Dis_Ascii(x,y,temp+0x30,front,back);
	mov R2,R14
	clr R3
	std y+5,R3
	std y+4,R2
	std y+2,R12
	subi R24,208    ; addi 48
	std y+0,R24
	mov R18,R22
	movw R16,R20
	xcall _Dis_Ascii
	.dbline 37
; 	x+=8;
	subi R20,248  ; offset = 8
	sbci R21,255
	.dbline 38
; 	temp = time.hour & 0x0f;
	lds R24,_time+2
	andi R24,15
	.dbline 39
; 	Dis_Ascii(x,y,temp+0x30,front,back);
	mov R2,R14
	clr R3
	std y+5,R3
	std y+4,R2
	std y+2,R12
	subi R24,208    ; addi 48
	std y+0,R24
	mov R18,R22
	movw R16,R20
	xcall _Dis_Ascii
	.dbline 40
; 	x+=8;
	subi R20,248  ; offset = 8
	sbci R21,255
	.dbline 41
; 	Dis_Ascii(x,y,':',front,back);
	mov R2,R14
	clr R3
	std y+5,R3
	std y+4,R2
	std y+2,R12
	ldi R24,58
	std y+0,R24
	mov R18,R22
	movw R16,R20
	xcall _Dis_Ascii
	.dbline 42
; 	x+=8;
	subi R20,248  ; offset = 8
	sbci R21,255
	.dbline 43
; 	temp = time.minute>>4;
	lds R24,_time+1
	swap R24
	andi R24,#0x0F
	.dbline 44
; 	Dis_Ascii(x,y,temp+0x30,front,back);
	mov R2,R14
	clr R3
	std y+5,R3
	std y+4,R2
	std y+2,R12
	subi R24,208    ; addi 48
	std y+0,R24
	mov R18,R22
	movw R16,R20
	xcall _Dis_Ascii
	.dbline 45
; 	x+=8;
	subi R20,248  ; offset = 8
	sbci R21,255
	.dbline 46
; 	temp = time.minute & 0x0f;
	lds R24,_time+1
	andi R24,15
	.dbline 47
; 	Dis_Ascii(x,y,temp+0x30,front,back);
	mov R2,R14
	clr R3
	std y+5,R3
	std y+4,R2
	std y+2,R12
	subi R24,208    ; addi 48
	std y+0,R24
	mov R18,R22
	movw R16,R20
	xcall _Dis_Ascii
	.dbline 48
; 	x+=8;
	subi R20,248  ; offset = 8
	sbci R21,255
	.dbline 49
; 	Dis_Ascii(x,y,':',front,back);
	mov R2,R14
	clr R3
	std y+5,R3
	std y+4,R2
	std y+2,R12
	ldi R24,58
	std y+0,R24
	mov R18,R22
	movw R16,R20
	xcall _Dis_Ascii
	.dbline 50
; 	x+=8;
	subi R20,248  ; offset = 8
	sbci R21,255
	.dbline 51
; 	temp = time.second>>4;
	lds R24,_time
	swap R24
	andi R24,#0x0F
	.dbline 52
; 	Dis_Ascii(x,y,temp+0x30,front,back);
	mov R2,R14
	clr R3
	std y+5,R3
	std y+4,R2
	std y+2,R12
	subi R24,208    ; addi 48
	std y+0,R24
	mov R18,R22
	movw R16,R20
	xcall _Dis_Ascii
	.dbline 53
; 	x+=8;
	subi R20,248  ; offset = 8
	sbci R21,255
	.dbline 54
; 	temp = time.second & 0x0f;
	lds R24,_time
	andi R24,15
	mov R10,R24
	.dbline 55
; 	Dis_Ascii(x,y,temp+0x30,front,back);
	mov R2,R14
	clr R3
	std y+5,R3
	std y+4,R2
	std y+2,R12
	subi R24,208    ; addi 48
	std y+0,R24
	mov R18,R22
	movw R16,R20
	xcall _Dis_Ascii
	.dbline -2
L11:
	adiw R28,6
	xcall pop_gset5
	.dbline 0 ; func end
	ret
	.dbsym r temp 10 c
	.dbsym r back 14 c
	.dbsym r front 12 c
	.dbsym r y 22 c
	.dbsym r x 20 i
	.dbend
	.dbfunc e DisTimeAll _DisTimeAll fV
;           temp -> y+7
;           back -> y+24
;          front -> y+22
;              y -> R22
;              x -> R20,R21
	.even
_DisTimeAll::
	xcall push_gset2
	mov R22,R18
	movw R20,R16
	sbiw R28,18
	.dbline -1
	.dbline 59
; 	
; }
; void DisTimeAll(unsigned int x,unsigned char y,unsigned char front,unsigned char back)
; {
	.dbline 61
;     unsigned char temp[11];
; 	ReadTime();
	xcall _ReadTime
	.dbline 62
; 	temp[0] = (time.year_H >> 4)+0x30;
	lds R24,_time+6
	swap R24
	andi R24,#0x0F
	subi R24,208    ; addi 48
	std y+7,R24
	.dbline 63
; 	temp[1] = (time.year_H &0x0f)+0x30;
	lds R24,_time+6
	andi R24,15
	subi R24,208    ; addi 48
	std y+8,R24
	.dbline 64
; 	temp[2] = (time.year_L >> 4)+0x30;
	lds R24,_time+5
	swap R24
	andi R24,#0x0F
	subi R24,208    ; addi 48
	std y+9,R24
	.dbline 65
; 	temp[3] = (time.year_L & 0x0f)+0x30;
	lds R24,_time+5
	andi R24,15
	subi R24,208    ; addi 48
	std y+10,R24
	.dbline 66
; 	temp[4] = '/';
	ldi R24,47
	std y+11,R24
	.dbline 67
; 	temp[5] = (time.month >> 4)+0x30;
	lds R24,_time+4
	swap R24
	andi R24,#0x0F
	subi R24,208    ; addi 48
	std y+12,R24
	.dbline 68
; 	temp[6] = (time.month & 0x0f)+0x30;
	lds R24,_time+4
	andi R24,15
	subi R24,208    ; addi 48
	std y+13,R24
	.dbline 69
; 	temp[7] = '/';
	ldi R24,47
	std y+14,R24
	.dbline 70
; 	temp[8] = (time.day >> 4)+0x30;
	lds R24,_time+3
	swap R24
	andi R24,#0x0F
	subi R24,208    ; addi 48
	std y+15,R24
	.dbline 71
; 	temp[9] = (time.day & 0x0f)+0x30;
	lds R24,_time+3
	andi R24,15
	subi R24,208    ; addi 48
	std y+16,R24
	.dbline 72
; 	temp[10] = 0;
	clr R2
	std y+17,R2
	.dbline 73
; 	Display(x,y,temp,BIG,front,back);
	ldd R0,y+24
	std y+6,R0
	ldd R0,y+22
	std y+4,R0
	ldi R24,1
	std y+2,R24
	movw R24,R28
	adiw R24,7
	std y+1,R25
	std y+0,R24
	mov R18,R22
	movw R16,R20
	xcall _Display
	.dbline 75
; 	
; 	temp[0] = (time.hour >> 4)+0x30;
	lds R24,_time+2
	swap R24
	andi R24,#0x0F
	subi R24,208    ; addi 48
	std y+7,R24
	.dbline 76
; 	temp[1] = (time.hour & 0x0f)+0x30;
	lds R24,_time+2
	andi R24,15
	subi R24,208    ; addi 48
	std y+8,R24
	.dbline 77
; 	temp[2] = '/';
	ldi R24,47
	std y+9,R24
	.dbline 78
; 	temp[3] = (time.minute >> 4)+0x30;
	lds R24,_time+1
	swap R24
	andi R24,#0x0F
	subi R24,208    ; addi 48
	std y+10,R24
	.dbline 79
; 	temp[4] = (time.minute & 0x0f)+0x30;
	lds R24,_time+1
	andi R24,15
	subi R24,208    ; addi 48
	std y+11,R24
	.dbline 80
; 	temp[5] = '/';
	ldi R24,47
	std y+12,R24
	.dbline 81
; 	temp[6] = (time.second >> 4)+0x30;
	lds R24,_time
	swap R24
	andi R24,#0x0F
	subi R24,208    ; addi 48
	std y+13,R24
	.dbline 82
; 	temp[7] = (time.second & 0x0f)+0x30;
	lds R24,_time
	andi R24,15
	subi R24,208    ; addi 48
	std y+14,R24
	.dbline 83
; 	temp[8] = 0;
	clr R2
	std y+15,R2
	.dbline 84
; 	Display(x+32,y+25,temp,BIG,front,back);
	ldd R0,y+24
	std y+6,R0
	ldd R0,y+22
	std y+4,R0
	ldi R24,1
	std y+2,R24
	movw R24,R28
	adiw R24,7
	std y+1,R25
	std y+0,R24
	mov R18,R22
	subi R18,231    ; addi 25
	movw R16,R20
	subi R16,224  ; offset = 32
	sbci R17,255
	xcall _Display
	.dbline -2
L16:
	adiw R28,18
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym l temp 7 A[11:11]c
	.dbsym l back 24 c
	.dbsym l front 22 c
	.dbsym r y 22 c
	.dbsym r x 20 i
	.dbend
	.dbfunc e SetTime _SetTime fV
	.even
_SetTime::
	.dbline -1
	.dbline 88
; 	
; }
; void SetTime(void)
; {
	.dbline 89
;     REG_B=0xb2;
	ldi R24,178
	sts 45067,R24
	.dbline 90
;     SECOND = 0; //second
	clr R2
	sts 45056,R2
	.dbline 91
;     MINUTE = 0; //minutes
	sts 45058,R2
	.dbline 92
;     HOUR = 0;   //hour
	sts 45060,R2
	.dbline 93
;     DAY = 0;   //day
	sts 45063,R2
	.dbline 94
;     MONTH = 0;  //month
	sts 45064,R2
	.dbline 95
;     YEAR = 0;  //year
	sts 45065,R2
	.dbline 96
; 	REG_E = 0x20;//year high byte
	ldi R24,32
	sts 45070,R24
	.dbline 97
;     REG_A = 0x20;
	sts 45066,R24
	.dbline 98
; 	REG_B = 0x12;
	ldi R24,18
	sts 45067,R24
	.dbline -2
L47:
	.dbline 0 ; func end
	ret
	.dbend
	.area bss(ram, con, rel)
	.dbfile F:\Relations\sf6_system\measure\LCDtest\rtc.c
_time::
	.blkb 7
	.dbstruct 0 7 Time
	.dbfield 0 second c
	.dbfield 1 minute c
	.dbfield 2 hour c
	.dbfield 3 day c
	.dbfield 4 month c
	.dbfield 5 year_L c
	.dbfield 6 year_H c
	.dbend
	.dbsym e time _time S[Time]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -