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

📄 ds12887.s

📁 高精度时钟芯片。avr驱动
💻 S
📖 第 1 页 / 共 3 页
字号:
	mov R22,R16
	.dbline -1
	.dbline 156
; }
; /*******************************************
; 函数名称: LCD1602_gotoXY
; 功    能: 移动到指定位置
; 参    数: Row--指定的行
; 	  	  Col--指定的列
; 返回值  : 无
; /********************************************/
; void LCD1602_gotoXY(uchar Row, uchar Col)
; {	
	.dbline 157
; 	switch (Row)		  //选择行
	clr R23
	cpi R22,2
	ldi R30,0
	cpc R23,R30
	breq L35
	xjmp L32
X0:
	.dbline 158
; 	{
L35:
	.dbline 160
; 		case 2:
; 			LCD1602_sendbyte(iCmd, LCDa_L2 + Col); break;	//写入第2行的指定列	
	mov R18,R20
	subi R18,64    ; addi 192
	clr R16
	xcall _LCD1602_sendbyte
	.dbline 160
	xjmp L33
L32:
	.dbline 162
	mov R18,R20
	subi R18,128    ; addi 128
	clr R16
	xcall _LCD1602_sendbyte
	.dbline 162
L33:
	.dbline -2
	.dbline 164
; 		default:
; 			LCD1602_sendbyte(iCmd, LCDa_L1 + Col); break;	//写入第1行的指定列	
; 	}
; }
L31:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r Col 20 c
	.dbsym r Row 22 c
	.dbend
	.dbfunc e LCD1602_initial _LCD1602_initial fV
	.even
_LCD1602_initial::
	.dbline -1
	.dbline 172
; /*******************************************
; 函数名称: LCD1602_initial
; 功    能: 1602液晶初始化
; 参    数: 无
; 返回值  : 无
; /********************************************/
; void LCD1602_initial(void)
; {
	.dbline 173
; 	Delayms(100);				//上电后等待内部复位
	ldi R16,100
	ldi R17,0
	xcall _Delayms
	.dbline 174
; 	LCD1602_portini();			//端口初始化
	xcall _LCD1602_portini
	.dbline 176
; 	
; 	LCD1602_sendbyte(iCmd, LCDa_FUNCTION);	//功能、模式设定,具体的设定功能可以看C:\icc\include\AVR_PQ1A.H里面的常量定义
	ldi R18,56
	clr R16
	xcall _LCD1602_sendbyte
L37:
	.dbline 177
L38:
	.dbline 177
; 	while(LCD1602_readBF());				//等待不忙为止
	xcall _LCD1602_readBF
	tst R16
	brne L37
	.dbline 178
; 	LCD1602_sendbyte(iCmd, LCDa_ON);		//打开显示
	ldi R18,12
	clr R16
	xcall _LCD1602_sendbyte
L40:
	.dbline 179
L41:
	.dbline 179
; 	while(LCD1602_readBF());				//等待不忙为止
	xcall _LCD1602_readBF
	tst R16
	brne L40
	.dbline 180
; 	LCD1602_clear();						//清屏
	xcall _LCD1602_clear
L43:
	.dbline 181
L44:
	.dbline 181
; 	while(LCD1602_readBF());				//等待不忙为止
	xcall _LCD1602_readBF
	tst R16
	brne L43
	.dbline 182
; 	LCD1602_sendbyte(iCmd, LCDa_ENTRY);		//输入模式设定		
	ldi R18,6
	clr R16
	.dbline -2
	.dbline 183
; }
L36:
	.dbline 0 ; func end
	xjmp _LCD1602_sendbyte
	.dbend
	.dbfunc e write_ds _write_ds fV
;           date -> R20
;            add -> R22
	.even
_write_ds::
	xcall push_gset2
	mov R20,R18
	mov R22,R16
	.dbline -1
	.dbline 186
; 
; void write_ds(uchar add,uchar date)
; {
	.dbline 187
;    PORTC&=~BIT(RTC_CS);		  //选通时钟
	cbi 0x15,0
	.dbline 188
;    PORTD|=BIT(RTC_AS);
	sbi 0x12,5
	.dbline 189
;    PORTD|=BIT(RTC_DS);
	sbi 0x12,7
	.dbline 190
;    PORTD|=BIT(RTC_RW);   
	sbi 0x12,6
	.dbline 191
;    PORTA=add;
	out 0x1b,R22
	.dbline 192
;    Delayus(5);
	ldi R16,5
	ldi R17,0
	xcall _Delayus
	.dbline 193
;    PORTD&=~BIT(RTC_AS);		  //锁存地址
	cbi 0x12,5
	.dbline 194
;    PORTD&=~BIT(RTC_RW);		  
	cbi 0x12,6
	.dbline 195
;    PORTA=date;		   		  
	out 0x1b,R20
	.dbline 196
;    Delayus(5);   
	ldi R16,5
	ldi R17,0
	xcall _Delayus
	.dbline 197
;    PORTD|=BIT(RTC_RW);       //写数据  
	sbi 0x12,6
	.dbline 198
;    PORTD|=BIT(RTC_AS);
	sbi 0x12,5
	.dbline 199
;    PORTC|=BIT(RTC_CS);				
	sbi 0x15,0
	.dbline -2
	.dbline 200
; }
L46:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r date 20 c
	.dbsym r add 22 c
	.dbend
	.dbfunc e read_ds _read_ds fc
;        ds_date -> R20
;            add -> R20
	.even
_read_ds::
	xcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 203
; 
; uchar read_ds(uchar add)
; {
	.dbline 205
;    uchar ds_date;  
;    PORTC&=~BIT(RTC_CS);	 		//选通时钟
	cbi 0x15,0
	.dbline 206
;    PORTD|=BIT(RTC_AS);
	sbi 0x12,5
	.dbline 207
;    PORTD|=BIT(RTC_DS);
	sbi 0x12,7
	.dbline 208
;    PORTD|=BIT(RTC_RW);
	sbi 0x12,6
	.dbline 210
; //   PORTC&=~BIT(RTC_CS);	 		//选通时钟
;    PORTA=add;
	out 0x1b,R20
	.dbline 211
;    Delayus(5);
	ldi R16,5
	ldi R17,0
	xcall _Delayus
	.dbline 212
;    PORTD&=~BIT(RTC_AS);			//锁存地址   
	cbi 0x12,5
	.dbline 213
;    PORTD&=~BIT(RTC_DS);
	cbi 0x12,7
	.dbline 214
;    DDRA=0;
	clr R2
	out 0x1a,R2
	.dbline 216
; //   PORTA=0XFF;
;    Delayus(5);
	ldi R16,5
	ldi R17,0
	xcall _Delayus
	.dbline 217
;    ds_date=PINA;	   			//读数据
	in R20,0x19
	.dbline 218
;    DDRA=0XFF;
	ldi R24,255
	out 0x1a,R24
	.dbline 219
;    PORTD|=BIT(RTC_DS);
	sbi 0x12,7
	.dbline 220
;    PORTD|=BIT(RTC_AS);
	sbi 0x12,5
	.dbline 221
;    PORTC|=BIT(RTC_CS);         
	sbi 0x15,0
	.dbline 222
;    return ds_date;	
	mov R16,R20
	.dbline -2
L47:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r ds_date 20 c
	.dbsym r add 20 c
	.dbend
	.dbfunc e StartDs12c887 _StartDs12c887 fV
	.even
_StartDs12c887::
	.dbline -1
	.dbline 233
; }
; 
; 
; /************************************************************* 
; 函数功能:该函数用来启动时钟芯片工作
; 应用范围:仅在时钟芯片首次使用时用到一次
; 入口参数:
; 出口参数:
; *************************************************************/   
; void StartDs12c887(void)
; {
	.dbline 234
;    write_ds(chRegA,CMD_START_DS12C887);
	ldi R18,32
	ldi R16,10
	.dbline -2
	.dbline 235
; }
L48:
	.dbline 0 ; func end
	xjmp _write_ds
	.dbend
	.dbfunc e CloseDs12c887 _CloseDs12c887 fV
	.even
_CloseDs12c887::
	.dbline -1
	.dbline 244
; 
; /************************************************************* 
; 函数功能:该函数用来关闭时钟芯片
; 应用范围:一般用不到
; 入口参数:
; 出口参数:
; *************************************************************/   
; void CloseDs12c887(void)
; {
	.dbline 245
;    write_ds(chRegA,CMD_CLOSE_DS12C887);
	ldi R18,48
	ldi R16,10
	.dbline -2
	.dbline 246
; }
L49:
	.dbline 0 ; func end
	xjmp _write_ds
	.dbend
	.dbfunc e InitDs12c887 _InitDs12c887 fV
	.even
_InitDs12c887::
	.dbline -1
	.dbline 254
; /************************************************************* 
; 函数功能:初始化ds12c887
; 应用范围:
; 入口参数:
; 出口参数:
; *************************************************************/   
; void InitDs12c887()
; {
	.dbline 255
;     StartDs12c887();
	xcall _StartDs12c887
	.dbline 256
; 	write_ds(chRegB,chRegB | MASK_SETB_SET);/* 禁止刷新 */
	ldi R18,139
	ldi R16,11
	xcall _write_ds
	.dbline 257
; 	write_ds(chRegB,chRegB & MASK_CLR_DM | MASK_SETB_2412 & MASK_CLR_DSE);
	ldi R18,11
	ldi R16,11
	xcall _write_ds
	.dbline 260
;                             
;                 /* 使用BCD码格式、24小时模式、不使用夏令时 */
; 	write_ds(chCenturyChannel,0x21);               /* 设置为21世纪 */
	ldi R18,33
	ldi R16,50
	xcall _write_ds
	.dbline 261
; 	write_ds(chRegB,chRegB & MASK_CLR_SET);
	ldi R18,11
	ldi R16,11
	.dbline -2
	.dbline 262
; }
L50:
	.dbline 0 ; func end
	xjmp _write_ds
	.dbend
	.dbfunc e GetSeconds _GetSeconds fc
	.even
_GetSeconds::
	.dbline -1
	.dbline 271
; 
; /************************************************************* 
; 函数功能:该函数用来从时钟芯片读取秒字节
; 应用范围:
; 入口参数:
; 出口参数:
; *************************************************************/   
; unsigned char GetSeconds(void)
; {
	.dbline 272
;     return(read_ds(chSecondsChannel));
	clr R16
	.dbline -2
L51:
	.dbline 0 ; func end
	xjmp _read_ds
	.dbend
	.dbfunc e GetMinutes _GetMinutes fc
	.even
_GetMinutes::
	.dbline -1
	.dbline 282
; }
; 
; /************************************************************* 
; 函数功能:该函数用来从时钟芯片读取分字节
; 应用范围:
; 入口参数:
; 出口参数:
; *************************************************************/   
; unsigned char GetMinutes(void)
; {
	.dbline 283
;     return(read_ds(chMinutesChannel));
	ldi R16,2
	.dbline -2
L52:
	.dbline 0 ; func end
	xjmp _read_ds
	.dbend
	.dbfunc e GetHours _GetHours fc
	.even
_GetHours::
	.dbline -1
	.dbline 293
; }
; 
; /************************************************************* 
; 函数功能:该函数用来从时钟芯片读取小时字节
; 应用范围:
; 入口参数:
; 出口参数:
; *************************************************************/   
; unsigned char GetHours(void)
; {
	.dbline 294
;     return(read_ds(chHoursChannel));
	ldi R16,4
	.dbline -2
L53:
	.dbline 0 ; func end
	xjmp _read_ds
	.dbend
	.dbfunc e GetDate _GetDate fc
	.even
_GetDate::
	.dbline -1
	.dbline 304
; }
; 
; /************************************************************* 
; 函数功能:该函数用来从时钟芯片读取日字节
; 应用范围:
; 入口参数:
; 出口参数:
; *************************************************************/   
; unsigned char GetDate(void)
; {
	.dbline 305
;     return(read_ds(chDateChannel));
	ldi R16,7
	.dbline -2
L54:
	.dbline 0 ; func end
	xjmp _read_ds
	.dbend
	.dbfunc e GetMonth _GetMonth fc
	.even
_GetMonth::
	.dbline -1
	.dbline 314
; }
; /************************************************************* 
; 函数功能:该函数用来从时钟芯片读取月字节
; 应用范围:
; 入口参数:
; 出口参数:
; *************************************************************/   
; unsigned char GetMonth(void)
; {
	.dbline 315
;     return(read_ds(chMonthChannel));
	ldi R16,8
	.dbline -2
L55:
	.dbline 0 ; func end
	xjmp _read_ds
	.dbend
	.dbfunc e GetYear _GetYear fc
	.even
_GetYear::
	.dbline -1
	.dbline 325
; }
; 
; /************************************************************* 
; 函数功能:该函数用来从时钟芯片读取年字节
; 应用范围:
; 入口参数:
; 出口参数:
; *************************************************************/   
; unsigned char GetYear(void)
; {
	.dbline 326
;     return(read_ds(chYearChannel));
	ldi R16,9
	.dbline -2
L56:
	.dbline 0 ; func end
	xjmp _read_ds
	.dbend
	.dbfunc e GetCentury _GetCentury fc
	.even
_GetCentury::
	.dbline -1
	.dbline 336
; }
; 
; /************************************************************* 
; 函数功能:该函数用来从时钟芯片读取世纪字节
; 应用范围:
; 入口参数:
; 出口参数:
; *************************************************************/   
; unsigned char GetCentury(void)
; {
	.dbline 337
;     return(read_ds(chCenturyChannel));
	ldi R16,50
	.dbline -2
L57:
	.dbline 0 ; func end
	xjmp _read_ds
	.dbend
	.dbfunc e SetTime _SetTime fV
;        chHours -> y+4
;      chMinutes -> R20
;      chSeconds -> R22
	.even
_SetTime::
	xcall push_gset2
	mov R20,R18
	mov R22,R16
	.dbline -1
	.dbline 348
; }    
; 
; /************************************************************* 
; 函数功能:该函数用来设置时钟芯片的时间
; 应用范围:
; 入口参数:chSeconds、chMinutes、chHours是设定时间的压缩BCD码
; 出口参数:
; *************************************************************/   
; void SetTime(unsigned char chSeconds,unsigned char chMinutes,unsigned char 
; chHours)
; {
	.dbline 349
;    write_ds(chRegB,chRegB | MASK_SETB_SET);  /* 禁止刷新 */
	ldi R18,139
	ldi R16,11
	xcall _write_ds
	.dbline 350
;    write_ds(chSecondsChannel,chSeconds);
	mov R18,R22
	clr R16

⌨️ 快捷键说明

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