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

📄 ds1302.ls

📁 STM8s
💻 LS
字号:
   1                     ; C Compiler for STM8 (COSMIC Software)
   2                     ; Generator V4.2.8 - 03 Dec 2008
  79                     ; 6 void Write1302(unsigned char add,unsigned char data)
  79                     ; 7 {
  81                     	switch	.text
  82  0000               _Write1302:
  84  0000 89            	pushw	x
  85  0001 89            	pushw	x
  86       00000002      OFST:	set	2
  89                     ; 9 	data_h = (data/10)<<4;
  91  0002 9f            	ld	a,xl
  92  0003 ae000a        	ldw	x,#10
  93  0006 51            	exgw	x,y
  94  0007 5f            	clrw	x
  95  0008 97            	ld	xl,a
  96  0009 65            	divw	x,y
  97  000a 9f            	ld	a,xl
  98  000b 97            	ld	xl,a
  99  000c a610          	ld	a,#16
 100  000e 42            	mul	x,a
 101  000f 9f            	ld	a,xl
 102  0010 6b01          	ld	(OFST-1,sp),a
 103                     ; 10 	data_l = data_h|(data%10);
 105  0012 7b04          	ld	a,(OFST+2,sp)
 106  0014 ae000a        	ldw	x,#10
 107  0017 51            	exgw	x,y
 108  0018 5f            	clrw	x
 109  0019 97            	ld	xl,a
 110  001a 65            	divw	x,y
 111  001b 909f          	ld	a,yl
 112  001d 1a01          	or	a,(OFST-1,sp)
 113  001f 6b01          	ld	(OFST-1,sp),a
 114                     ; 11 	DS1302_OUT_PP;
 116  0021 c65011        	ld	a,20497
 117  0024 aa1c          	or	a,#28
 118  0026 c75011        	ld	20497,a
 121  0029 c65012        	ld	a,20498
 122  002c aa1c          	or	a,#28
 123  002e c75012        	ld	20498,a
 126  0031 c65013        	ld	a,20499
 127  0034 a4e3          	and	a,#227
 128  0036 c75013        	ld	20499,a
 129                     ; 13 	DS1302_CE_L;
 132  0039 7219500f      	bres	20495,#4
 133                     ; 14 	DS1302_SCLK_L;
 135  003d 7215500f      	bres	20495,#2
 136                     ; 15 	DS1302_CE_H;
 138  0041 7218500f      	bset	20495,#4
 139                     ; 16 	for(i=0;i<8;i++)
 141  0045 0f02          	clr	(OFST+0,sp)
 142  0047               L74:
 143                     ; 18 		DS1302_SCLK_L;
 145  0047 7215500f      	bres	20495,#2
 146                     ; 19 		if(add&0x01)
 148  004b 7b03          	ld	a,(OFST+1,sp)
 149  004d a501          	bcp	a,#1
 150  004f 2706          	jreq	L55
 151                     ; 20 			DS1302_DIO_H;
 153  0051 7216500f      	bset	20495,#3
 155  0055 2004          	jra	L75
 156  0057               L55:
 157                     ; 22 			DS1302_DIO_L;
 159  0057 7217500f      	bres	20495,#3
 160  005b               L75:
 161                     ; 23 		add>>=1;
 163  005b 0403          	srl	(OFST+1,sp)
 164                     ; 24 		DS1302_SCLK_H;
 166  005d 7214500f      	bset	20495,#2
 167                     ; 16 	for(i=0;i<8;i++)
 169  0061 0c02          	inc	(OFST+0,sp)
 172  0063 7b02          	ld	a,(OFST+0,sp)
 173  0065 a108          	cp	a,#8
 174  0067 25de          	jrult	L74
 175                     ; 26 	for(i=0;i<8;i++)
 177  0069 0f02          	clr	(OFST+0,sp)
 178  006b               L16:
 179                     ; 28 		DS1302_SCLK_L;
 181  006b 7215500f      	bres	20495,#2
 182                     ; 29 		if(data_l&0x01)
 184  006f 7b01          	ld	a,(OFST-1,sp)
 185  0071 a501          	bcp	a,#1
 186  0073 2706          	jreq	L76
 187                     ; 30 			DS1302_DIO_H;
 189  0075 7216500f      	bset	20495,#3
 191  0079 2004          	jra	L17
 192  007b               L76:
 193                     ; 32 			DS1302_DIO_L;
 195  007b 7217500f      	bres	20495,#3
 196  007f               L17:
 197                     ; 33 		data_l>>=1;
 199  007f 0401          	srl	(OFST-1,sp)
 200                     ; 34 		DS1302_SCLK_H;
 202  0081 7214500f      	bset	20495,#2
 203                     ; 26 	for(i=0;i<8;i++)
 205  0085 0c02          	inc	(OFST+0,sp)
 208  0087 7b02          	ld	a,(OFST+0,sp)
 209  0089 a108          	cp	a,#8
 210  008b 25de          	jrult	L16
 211                     ; 36 	DS1302_CE_L;
 213  008d 7219500f      	bres	20495,#4
 214                     ; 37 }
 217  0091 5b04          	addw	sp,#4
 218  0093 81            	ret
 282                     ; 40 unsigned char Read1302(unsigned char add)
 282                     ; 41 {
 283                     	switch	.text
 284  0094               _Read1302:
 286  0094 88            	push	a
 287  0095 5203          	subw	sp,#3
 288       00000003      OFST:	set	3
 291                     ; 43 	DS1302_OUT_PP;
 293  0097 c65011        	ld	a,20497
 294  009a aa1c          	or	a,#28
 295  009c c75011        	ld	20497,a
 298  009f c65012        	ld	a,20498
 299  00a2 aa1c          	or	a,#28
 300  00a4 c75012        	ld	20498,a
 303  00a7 c65013        	ld	a,20499
 304  00aa a4e3          	and	a,#227
 305  00ac c75013        	ld	20499,a
 306                     ; 44 	add += 1;
 309  00af 0c04          	inc	(OFST+1,sp)
 310                     ; 45 	DS1302_CE_L;
 312  00b1 7219500f      	bres	20495,#4
 313                     ; 46 	DS1302_SCLK_L;
 315  00b5 7215500f      	bres	20495,#2
 316                     ; 47 	DS1302_CE_H;
 318  00b9 7218500f      	bset	20495,#4
 319                     ; 48 	for(i=0;i<8;i++)
 321  00bd 0f03          	clr	(OFST+0,sp)
 322  00bf               L521:
 323                     ; 50 		DS1302_SCLK_L;
 325  00bf 7215500f      	bres	20495,#2
 326                     ; 51 		if(add&0x01)
 328  00c3 7b04          	ld	a,(OFST+1,sp)
 329  00c5 a501          	bcp	a,#1
 330  00c7 2706          	jreq	L331
 331                     ; 52 			DS1302_DIO_H;
 333  00c9 7216500f      	bset	20495,#3
 335  00cd 2004          	jra	L531
 336  00cf               L331:
 337                     ; 54 			DS1302_DIO_L;
 339  00cf 7217500f      	bres	20495,#3
 340  00d3               L531:
 341                     ; 55 		add>>=1;
 343  00d3 0404          	srl	(OFST+1,sp)
 344                     ; 56 		DS1302_SCLK_H;
 346  00d5 7214500f      	bset	20495,#2
 347                     ; 48 	for(i=0;i<8;i++)
 349  00d9 0c03          	inc	(OFST+0,sp)
 352  00db 7b03          	ld	a,(OFST+0,sp)
 353  00dd a108          	cp	a,#8
 354  00df 25de          	jrult	L521
 355                     ; 58 	DS1302_DIO_IN_PU_NO_IT;
 357  00e1 72175011      	bres	20497,#3
 360  00e5 72165012      	bset	20498,#3
 363  00e9 72175013      	bres	20499,#3
 364                     ; 59 	for(i=0;i<8;i++)
 367  00ed 0f03          	clr	(OFST+0,sp)
 368  00ef               L731:
 369                     ; 61 		if(DS1302_DIO_IN)
 371  00ef c65010        	ld	a,20496
 372  00f2 a508          	bcp	a,#8
 373  00f4 2706          	jreq	L541
 374                     ; 62 			temp_l |= 0x80;
 376  00f6 7b02          	ld	a,(OFST-1,sp)
 377  00f8 aa80          	or	a,#128
 378  00fa 6b02          	ld	(OFST-1,sp),a
 379  00fc               L541:
 380                     ; 63 		DS1302_SCLK_H;
 382  00fc 7214500f      	bset	20495,#2
 383                     ; 64 		nop();
 386  0100 9d            nop
 388                     ; 65 		nop();
 392  0101 9d            nop
 394                     ; 66 		nop();
 398  0102 9d            nop
 400                     ; 67 		temp_l >>=1;
 403  0103 0402          	srl	(OFST-1,sp)
 404                     ; 68 		DS1302_SCLK_L;
 406  0105 7215500f      	bres	20495,#2
 407                     ; 59 	for(i=0;i<8;i++)
 409  0109 0c03          	inc	(OFST+0,sp)
 412  010b 7b03          	ld	a,(OFST+0,sp)
 413  010d a108          	cp	a,#8
 414  010f 25de          	jrult	L731
 415                     ; 70 	DS1302_CE_L;
 417  0111 7219500f      	bres	20495,#4
 418                     ; 71 	temp_h = ((temp_l>>4)*10)+(temp_l&0x0f);
 420  0115 7b02          	ld	a,(OFST-1,sp)
 421  0117 a40f          	and	a,#15
 422  0119 6b01          	ld	(OFST-2,sp),a
 423  011b 7b02          	ld	a,(OFST-1,sp)
 424  011d 4e            	swap	a
 425  011e a40f          	and	a,#15
 426  0120 97            	ld	xl,a
 427  0121 a60a          	ld	a,#10
 428  0123 42            	mul	x,a
 429  0124 9f            	ld	a,xl
 430  0125 1b01          	add	a,(OFST-2,sp)
 431  0127 6b02          	ld	(OFST-1,sp),a
 432                     ; 72 	return temp_h;
 434  0129 7b02          	ld	a,(OFST-1,sp)
 437  012b 5b04          	addw	sp,#4
 438  012d 81            	ret
 518                     ; 74 void Set1302(unsigned char year,unsigned char month,unsigned char date,
 518                     ; 75 unsigned char day,unsigned char hour,unsigned char min)
 518                     ; 76 {
 519                     	switch	.text
 520  012e               _Set1302:
 522  012e 89            	pushw	x
 523       00000000      OFST:	set	0
 526                     ; 77 	Write1302(PROTECT,0);
 528  012f 5f            	clrw	x
 529  0130 a68e          	ld	a,#142
 530  0132 95            	ld	xh,a
 531  0133 cd0000        	call	_Write1302
 533                     ; 79 	Write1302(SECOND,0x00);//启动时钟,0x80停止时钟
 535  0136 5f            	clrw	x
 536  0137 a680          	ld	a,#128
 537  0139 95            	ld	xh,a
 538  013a cd0000        	call	_Write1302
 540                     ; 80 	Write1302(MINUTE,min);
 542  013d 7b08          	ld	a,(OFST+8,sp)
 543  013f 97            	ld	xl,a
 544  0140 a682          	ld	a,#130
 545  0142 95            	ld	xh,a
 546  0143 cd0000        	call	_Write1302
 548                     ; 81 	Write1302(HOUR,hour);
 550  0146 7b07          	ld	a,(OFST+7,sp)
 551  0148 97            	ld	xl,a
 552  0149 a684          	ld	a,#132
 553  014b 95            	ld	xh,a
 554  014c cd0000        	call	_Write1302
 556                     ; 82 	Write1302(DATE,date);
 558  014f 7b05          	ld	a,(OFST+5,sp)
 559  0151 97            	ld	xl,a
 560  0152 a686          	ld	a,#134
 561  0154 95            	ld	xh,a
 562  0155 cd0000        	call	_Write1302
 564                     ; 83 	Write1302(MONTH,month);
 566  0158 7b02          	ld	a,(OFST+2,sp)
 567  015a 97            	ld	xl,a
 568  015b a688          	ld	a,#136
 569  015d 95            	ld	xh,a
 570  015e cd0000        	call	_Write1302
 572                     ; 84 	Write1302(DAY,day);//week
 574  0161 7b06          	ld	a,(OFST+6,sp)
 575  0163 97            	ld	xl,a
 576  0164 a68a          	ld	a,#138
 577  0166 95            	ld	xh,a
 578  0167 cd0000        	call	_Write1302
 580                     ; 85 	Write1302(YEAR,year);//年
 582  016a 7b01          	ld	a,(OFST+1,sp)
 583  016c 97            	ld	xl,a
 584  016d a68c          	ld	a,#140
 585  016f 95            	ld	xh,a
 586  0170 cd0000        	call	_Write1302
 588                     ; 87 	Write1302(PROTECT,0x80);
 590  0173 ae0080        	ldw	x,#128
 591  0176 a68e          	ld	a,#142
 592  0178 95            	ld	xh,a
 593  0179 cd0000        	call	_Write1302
 595                     ; 88 }
 598  017c 85            	popw	x
 599  017d 81            	ret
 612                     	xdef	_Set1302
 613                     	xdef	_Read1302
 614                     	xdef	_Write1302
 633                     	end

⌨️ 快捷键说明

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