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

📄 ds12997.s

📁 本程序经调试好使
💻 S
📖 第 1 页 / 共 2 页
字号:
;     _NOP(); 
	nop
	.dbline 191
;     _NOP(); 
	nop
	.dbline 192
;     P_AS_1;            //锁存信号高电平 
	sbi 0x18,3
	.dbline 193
;     _NOP(); 
	nop
	.dbline 194
;     _NOP(); 
	nop
	.dbline 195
;     AD_DDR = 0xFF;         //数据口设置为输出 
	ldi R24,255
	out 0x1a,R24
	.dbline 196
; 	_NOP();
	nop
	.dbline 197
; 	_NOP();
	nop
	.dbline 198
; 	_NOP();
	nop
	.dbline 199
; 	_NOP();
	nop
	.dbline 200
;     AD_PORT = Address;       //给出地址 
	out 0x1b,R16
	.dbline 201
;     _NOP(); 
	nop
	.dbline 202
;     _NOP(); 
	nop
	.dbline 203
; 	 _NOP(); 
	nop
	.dbline 204
;     _NOP();
	nop
	.dbline 205
; 	_NOP();
	nop
	.dbline 206
; 	_NOP();
	nop
	.dbline 207
; 	_NOP();
	nop
	.dbline 208
; 	_NOP();
	nop
	.dbline 209
;     P_AS_0;            //锁存信号低电平 
	cbi 0x18,3
	.dbline 210
;     _NOP(); 
	nop
	.dbline 211
;     _NOP();     
	nop
	.dbline 212
;     P_DS_0;            //给出写信号 
	cbi 0x18,1
	.dbline 213
;     _NOP(); 
	nop
	.dbline 214
;     _NOP(); 
	nop
	.dbline 215
;     AD_DDR = 0X00;          //端口方向设置为输入 
	clr R2
	out 0x1a,R2
	.dbline 216
;     _NOP(); 
	nop
	.dbline 217
;     _NOP();
	nop
	.dbline 218
; 	_NOP();
	nop
	.dbline 219
; 	_NOP(); 
	nop
	.dbline 220
;     temp = AD_PIN;   //读入数据 
	in R20,0x19
	.dbline 221
;     _NOP();
	nop
	.dbline 222
; 	_NOP();
	nop
	.dbline 223
; 	_NOP();
	nop
	.dbline 224
; 	_NOP();
	nop
	.dbline 225
; 	_NOP();
	nop
	.dbline 226
; 	_NOP();
	nop
	.dbline 227
; 	_NOP();
	nop
	.dbline 228
; 	_NOP(); 
	nop
	.dbline 229
;     P_DS_1;            // 
	sbi 0x18,1
	.dbline 230
;     _NOP(); 
	nop
	.dbline 231
;     _NOP(); 
	nop
	.dbline 232
; 	P_AS_1;            // 
	sbi 0x18,3
	.dbline 233
;     _NOP(); 
	nop
	.dbline 234
;     _NOP(); 
	nop
	.dbline 235
;     return temp; 
	mov R16,R20
	.dbline -2
L26:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r temp 20 c
	.dbsym r Address 16 c
	.dbend
	.dbfunc e DS12887_Init _DS12887_Init fV
	.even
_DS12887_Init::
	.dbline -1
	.dbline 240
; }
; 
; //DS12887初始化
; void DS12887_Init(void)
; {
	.dbline 241
; 	DS12887_Write(0x0a, 0x20);	//打开振荡器,启动DS12887
	ldi R18,32
	ldi R16,10
	xcall _DS12887_Write
	.dbline 242
; 	DS12887_Write(0x0b, 0x86);	//禁止更新,接下来初始化数据,即写入时间,日期等
	ldi R18,134
	ldi R16,11
	xcall _DS12887_Write
	.dbline 243
; 	DS12887_Write(0x0b, 0x06);	//正常更新,二进制格式,24进制小时
	ldi R18,6
	ldi R16,11
	xcall _DS12887_Write
	.dbline -2
L27:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e DS12887_SetTime _DS12887_SetTime fV
;          Value -> R22
;        Address -> R20
	.even
_DS12887_SetTime::
	xcall push_gset2
	mov R22,R18
	mov R20,R16
	.dbline -1
	.dbline 250
; }
; 
; 
; 
; //设置时间函数
; void DS12887_SetTime( uchar Address,  uchar Value)
; {
	.dbline 251
; 	DS12887_Write(0x0b, 0x86);	//禁止更新,接下来初始化数据,即写入时间,日期等
	ldi R18,134
	ldi R16,11
	xcall _DS12887_Write
	.dbline 252
; 	DS12887_Write(Address,Value);
	mov R18,R22
	mov R16,R20
	xcall _DS12887_Write
	.dbline 253
; 	DS12887_Write(0x0b, 0x06);	//正常更新,二进制格式,24进制小时
	ldi R18,6
	ldi R16,11
	xcall _DS12887_Write
	.dbline -2
L28:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r Value 22 c
	.dbsym r Address 20 c
	.dbend
	.dbfunc e DS12887_GetTime _DS12887_GetTime fV
	.dbstruct 0 25 _SYSTEMTIME_
	.dbfield 0 Second c
	.dbfield 1 Minute c
	.dbfield 2 Hour c
	.dbfield 3 Week c
	.dbfield 4 Day c
	.dbfield 5 Month c
	.dbfield 6 Year c
	.dbfield 7 DateString A[9:9]c
	.dbfield 16 TimeString A[9:9]c
	.dbend
;           temp -> <dead>
;           Time -> R20,R21
	.even
_DS12887_GetTime::
	xcall push_gset1
	movw R20,R16
	.dbline -1
	.dbline 259
; }
; 
; 
; //读出时间
; void DS12887_GetTime(SYSTEMTIME *Time)
; {   uchar temp;
	.dbline 260
; 	Time->Second = DS12887_Read(DS12887_Second);
	clr R16
	xcall _DS12887_Read
	movw R30,R20
	std z+0,R16
	.dbline 261
; 	Time->Minute = DS12887_Read(DS12887_Minute);
	ldi R16,2
	xcall _DS12887_Read
	movw R30,R20
	std z+1,R16
	.dbline 262
; 	Time->Hour   = DS12887_Read(DS12887_Hour  );
	ldi R16,4
	xcall _DS12887_Read
	movw R30,R20
	std z+2,R16
	.dbline 263
; 	Time->Day    = DS12887_Read(DS12887_Day   );
	ldi R16,7
	xcall _DS12887_Read
	movw R30,R20
	std z+4,R16
	.dbline 265
; 	//Time->Week   = DS12887_Read(DS12887_Week  );
; 	Time->Month  = DS12887_Read(DS12887_Month );
	ldi R16,8
	xcall _DS12887_Read
	movw R30,R20
	std z+5,R16
	.dbline 266
; 	Time->Year   = DS12887_Read(DS12887_Year  );
	ldi R16,9
	xcall _DS12887_Read
	movw R30,R20
	std z+6,R16
	.dbline 268
;   
;   y1=DS12887_Read(DS12887_Second);
	clr R16
	xcall _DS12887_Read
	sts _y1,R16
	.dbline 269
;   y2=DS12887_Read(DS12887_Minute);
	ldi R16,2
	xcall _DS12887_Read
	sts _y2,R16
	.dbline 270
;   y3=DS12887_Read(DS12887_Hour  );
	ldi R16,4
	xcall _DS12887_Read
	sts _y3,R16
	.dbline 271
;   y4=DS12887_Read(DS12887_Day   );
	ldi R16,7
	xcall _DS12887_Read
	sts _y4,R16
	.dbline 272
;   y5=DS12887_Read(DS12887_Month );
	ldi R16,8
	xcall _DS12887_Read
	sts _y5,R16
	.dbline 273
;   y6=DS12887_Read(DS12887_Year  );
	ldi R16,9
	xcall _DS12887_Read
	sts _y6,R16
	.dbline -2
L29:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym l temp 1 c
	.dbsym r Time 20 pS[_SYSTEMTIME_]
	.dbend
	.dbfunc e port_init _port_init fV
	.even
_port_init::
	.dbline -1
	.dbline 278
; }
; 
; /*****************端口初始化********************************/
; void port_init(void) 
; {
	.dbline 279
;  DDRB  = 0xFF; 
	ldi R24,255
	out 0x17,R24
	.dbline 280
;  PORTB = 0xFF; //设为输出高电平
	out 0x18,R24
	.dbline 282
;  
;  DDRA  = 0x00; 
	clr R2
	out 0x1a,R2
	.dbline 283
;  PORTA = 0x00; //设为高阻态
	out 0x1b,R2
	.dbline -2
L30:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e init_devices _init_devices fV
	.even
_init_devices::
	.dbline -1
	.dbline 288
; 
; }
; /********************初始化器件************************************/
; void init_devices(void) 
; {
	.dbline 289
;  port_init();
	xcall _port_init
	.dbline -2
L31:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e main _main fV
;    CurrentTime -> y+0
	.even
_main::
	sbiw R28,25
	.dbline -1
	.dbline 296
;  }
; 
; 
; 
; /***************主函数*****************************/
; void main(void)
; {
	.dbline 298
; 	SYSTEMTIME CurrentTime;
;     init_devices();
	xcall _init_devices
	.dbline 300
; 	
; 	DS12887_Init();
	xcall _DS12887_Init
	.dbline 301
; 	 DS12887_GetTime(&CurrentTime);
	movw R16,R28
	xcall _DS12887_GetTime
	.dbline 304
; /*************时间初始化设置 ,2009-2-16 2:00:00************/
; //*
; DS12887_SetTime(DS12887_Second, 0); //设置秒
	clr R18
	clr R16
	xcall _DS12887_SetTime
	.dbline 305
; DS12887_SetTime(DS12887_Minute, 34); //设置分
	ldi R18,34
	ldi R16,2
	xcall _DS12887_SetTime
	.dbline 306
; DS12887_SetTime(DS12887_Hour,16);	 //设置时
	ldi R18,16
	ldi R16,4
	xcall _DS12887_SetTime
	.dbline 307
; DS12887_SetTime(DS12887_Day, 4);	 //设置天
	ldi R18,4
	ldi R16,7
	xcall _DS12887_SetTime
	.dbline 308
; DS12887_SetTime(DS12887_Month, 3); //设置月
	ldi R18,3
	ldi R16,8
	xcall _DS12887_SetTime
	.dbline 309
; DS12887_SetTime(DS12887_Year, 9);	 //设置年
	ldi R18,9
	ldi R16,9
	xcall _DS12887_SetTime
	xjmp L34
L33:
	.dbline 313
	.dbline 314
	movw R16,R28
	xcall _DS12887_GetTime
	.dbline 317
L34:
	.dbline 312
	xjmp L33
X1:
	.dbline -2
L32:
	adiw R28,25
	.dbline 0 ; func end
	ret
	.dbsym l CurrentTime 0 S[_SYSTEMTIME_]
	.dbend
	.area bss(ram, con, rel)
	.dbfile C:\DOCUME~1\wangqinbo\MYDOCU~1\avrc\ds12997.c
_y6::
	.blkb 1
	.dbsym e y6 _y6 c
_y5::
	.blkb 1
	.dbsym e y5 _y5 c
_y4::
	.blkb 1
	.dbsym e y4 _y4 c
_y3::
	.blkb 1
	.dbsym e y3 _y3 c
_y2::
	.blkb 1
	.dbsym e y2 _y2 c
_y1::
	.blkb 1
	.dbsym e y1 _y1 c

⌨️ 快捷键说明

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