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

📄 eeprom.la

📁 使用单片机mc68hc11f1对内部EEprom擦除的程序
💻 LA
字号:
   1                     ; C Compiler for MC68HC11 [COSMIC Software]
   2                     ; Generator V4.1t - 09 Mar 2005
   3                     ; Optimizer V4.1o - 12 Aug 2004
 460                     ; 7 void Init68hc11(void)
 460                     ; 8 {//BPROT=0X00;//可以修改config,低4位为EEprom的保护
 461                     	switch	.text
 462  8102               _Init68hc11:
 464  8102 3c            	pshx	
 467                     ; 10 INIT=0X21;//寄存器,RAM空间映像,01为复位值
 469  8103 c621          	ldab	#33
 470  8105 ce1000        	ldx	#4096
 471  8108 e73d          	stab	61,x
 472                     ; 15 CSCTL|=0x21;//64k
 474  810a 1c5d21        	bset	93,x,#33
 475                     ; 16 CSGSIZ|=0X40;
 477  810d 1c5f40        	bset	95,x,#64
 478                     ; 17 CSSTRH|=0x30;
 480  8110 1c5c30        	bset	92,x,#48
 481                     ; 19 }
 484  8113 38            	pulx	
 485  8114 39            	rts	
 536                     ; 21 void Delay(uchar n)
 536                     ; 22 {uchar i,j,k;
 537                     	switch	.text
 538  8115               _Delay:
 540  8115 bd8238        	jsr	c_kents
 541  8118 05            	dc.b	5
 542       00000005      OFST:	set	5
 545                     ; 24 	  for(i=0;i<n;i++)
 547  8119 6f04          	clr	OFST-1,x
 549  811b 2024          	bra	L732
 550  811d               L332:
 551                     ; 25 	  {		for (j=0;j<200;j++)
 553  811d 6f03          	clr	OFST-2,x
 554  811f               L342:
 555                     ; 26 		  {		for (k=0;k<10;k++)
 557  811f 6f02          	clr	OFST-3,x
 558  8121               L152:
 562  8121 6c02          	inc	OFST-3,x
 565  8123 e602          	ldab	OFST-3,x
 566  8125 c10a          	cmpb	#10
 567  8127 25f8          	blo	L152
 568                     ; 29 			COPRST=0X55;
 570  8129 c655          	ldab	#85
 571  812b 18ce1000      	ldy	#4096
 572  812f 18e73a        	stab	58,y
 573                     ; 30 			COPRST=0XAA;  
 575  8132 c6aa          	ldab	#170
 576  8134 18e73a        	stab	58,y
 577                     ; 25 	  {		for (j=0;j<200;j++)
 579  8137 6c03          	inc	OFST-2,x
 582  8139 e603          	ldab	OFST-2,x
 583  813b c1c8          	cmpb	#200
 584  813d 25e0          	blo	L342
 585                     ; 24 	  for(i=0;i<n;i++)
 587  813f 6c04          	inc	OFST-1,x
 588  8141               L732:
 591  8141 e604          	ldab	OFST-1,x
 592  8143 e106          	cmpb	OFST+1,x
 593  8145 25d6          	blo	L332
 594                     ; 34 }
 597  8147 ae00          	lds	0,x
 598  8149 38            	pulx	
 599  814a 39            	rts	
 620                     ; 36 void EepromInit(void)
 620                     ; 37 {
 621                     	switch	.text
 622  814b               _EepromInit:
 624  814b 3c            	pshx	
 627                     ; 40 PPROG=0X00;//复位时:00
 629  814c 5f            	clrb	
 630  814d ce1000        	ldx	#4096
 631  8150 e73b          	stab	59,x
 632                     ; 41 }
 635  8152 38            	pulx	
 636  8153 39            	rts	
 670                     ; 42 void EepromErase(uchar *addr)
 670                     ; 43 {//erase=(volatile unsigned char*)(0xfe00);
 671                     	switch	.text
 672  8154               _EepromErase:
 674  8154 3c            	pshx	
 675                     	pshd	
 676  8157 30            	tsx	
 677       00000000      OFST:	set	0
 680                     ; 45  erase=((volatile unsigned char*)(addr));
 682  8158 ec00          	ldd	OFST+0,x
 683  815a fd2000        	std	_erase
 684                     ; 48 {PPROG=0X16;//擦除方式 块擦除
 686  815d c616          	ldab	#22
 687  815f 18ce1000      	ldy	#4096
 688  8163 18e73b        	stab	59,y
 689                     ; 49 (*erase)=0xff;
 691  8166 c6ff          	ldab	#255
 692  8168 18fe2000      	ldy	_erase
 693  816c 18e700        	stab	0,y
 694                     ; 51 PPROG=0X17;//打开编程电源
 696  816f c617          	ldab	#23
 697  8171 18ce1000      	ldy	#4096
 698  8175 18e73b        	stab	59,y
 699                     ; 52 Delay(100);//延时10Ms
 701  8178 cc0064        	ldd	#100
 702  817b 8d98          	jsr	_Delay
 704                     ; 53 PPROG=0X00;//置为读出方式
 706  817d 5f            	clrb	
 707  817e 18ce1000      	ldy	#4096
 708  8182 18e73b        	stab	59,y
 709                     ; 55 }
 712  8185 38            	pulx	
 713  8186 38            	pulx	
 714  8187 39            	rts	
 736                     ; 57 void EepromBulkErase(void)
 736                     ; 58 {uchar *i;
 737                     	switch	.text
 738  8188               _EepromBulkErase:
 740  8188 3c            	pshx	
 743                     ; 59 PPROG=0X06;//擦除方式
 745  8189 c606          	ldab	#6
 746  818b ce1000        	ldx	#4096
 747  818e e73b          	stab	59,x
 748                     ; 64 EEPROMBASEADDRESS=0xdd;
 750  8190 c6dd          	ldab	#221
 751  8192 f70e00        	stab	3584
 752                     ; 66 PPROG=0X07;//打开编程电源
 754  8195 c607          	ldab	#7
 755  8197 e73b          	stab	59,x
 756                     ; 67 Delay(100);//延时10Ms
 758  8199 cc0064        	ldd	#100
 759  819c bd8115        	jsr	_Delay
 761                     ; 68 PPROG=0X00;//置为读出方式
 763  819f 5f            	clrb	
 764  81a0 ce1000        	ldx	#4096
 765  81a3 e73b          	stab	59,x
 766                     ; 83 }
 769  81a5 38            	pulx	
 770  81a6 39            	rts	
 811                     ; 87 void EepromByteWrite(uchar *aimaddr,uchar a)
 811                     ; 88 { //uchar *i;
 812                     	switch	.text
 813  81a7               _EepromByteWrite:
 815  81a7 3c            	pshx	
 816                     	pshd	
 817  81aa 30            	tsx	
 818       00000000      OFST:	set	0
 821                     ; 90 	erase=(aimaddr);
 823  81ab ec00          	ldd	OFST+0,x
 824  81ad fd2000        	std	_erase
 825                     ; 91 	PPROG=0X02;//允许锁存地址和数据
 827  81b0 c602          	ldab	#2
 828  81b2 18ce1000      	ldy	#4096
 829  81b6 18e73b        	stab	59,y
 830                     ; 92 	(*erase)=a;
 832  81b9 e607          	ldab	OFST+7,x
 833  81bb 18fe2000      	ldy	_erase
 834  81bf 18e700        	stab	0,y
 835                     ; 93 	PPROG=0X03;//加编程电压
 837  81c2 c603          	ldab	#3
 838  81c4 18ce1000      	ldy	#4096
 839  81c8 18e73b        	stab	59,y
 840                     ; 94 	Delay(20);//10ms
 842  81cb cc0014        	ldd	#20
 843  81ce bd8115        	jsr	_Delay
 845                     ; 95 	PPROG=0X00;//清除
 847  81d1 5f            	clrb	
 848  81d2 18ce1000      	ldy	#4096
 849  81d6 18e73b        	stab	59,y
 850                     ; 98 }
 853  81d9 38            	pulx	
 854  81da 38            	pulx	
 855  81db 39            	rts	
 920                     ; 100 void EepromWrite(uchar *aimaddr,uint number,uchar *source)
 920                     ; 101 { uchar i=0;
 921                     	switch	.text
 922  81dc               _EepromWrite:
 924  81dc bd8238        	jsr	c_kents
 925  81df 05            	dc.b	5
 926       00000005      OFST:	set	5
 931  81e0 6f02          	clr	OFST-3,x
 932                     ; 103 j=(volatile unsigned char*)(aimaddr);
 934  81e2 ec05          	ldd	OFST+0,x
 935  81e4 ed03          	std	OFST-2,x
 936                     ; 106 			for(i=0;i<(number);i++)						   //写入数据EEprom
 938  81e6 6f02          	clr	OFST-3,x
 940  81e8 2039          	bra	L163
 941  81ea               L553:
 942                     ; 107 				{PPROG=0X02;//允许锁存地址和数据
 944  81ea c602          	ldab	#2
 945  81ec 18ce1000      	ldy	#4096
 946  81f0 18e73b        	stab	59,y
 947                     ; 108 					(*j)=(*source);
 949  81f3 1aee0d        	ldy	OFST+8,x
 950  81f6 18e600        	ldab	0,y
 951  81f9 1aee03        	ldy	OFST-2,x
 952  81fc 18e700        	stab	0,y
 953                     ; 110 					source++;
 955  81ff 6c0e          	inc	OFST+9,x
 956  8201 2602          	bne	L02
 957  8203 6c0d          	inc	OFST+8,x
 958  8205               L02:
 959                     ; 111 					j++;
 961  8205 1808          	iny	
 962  8207 1aef03        	sty	OFST-2,x
 963                     ; 112 					PPROG=0X03;//加编程电压
 965  820a c603          	ldab	#3
 966  820c 18ce1000      	ldy	#4096
 967  8210 18e73b        	stab	59,y
 968                     ; 117 				Delay(2);//10ms
 970  8213 cc0002        	ldd	#2
 971  8216 bd8115        	jsr	_Delay
 973                     ; 118 				PPROG=0X00;//清除
 975  8219 5f            	clrb	
 976  821a 18ce1000      	ldy	#4096
 977  821e 18e73b        	stab	59,y
 978                     ; 106 			for(i=0;i<(number);i++)						   //写入数据EEprom
 980  8221 6c02          	inc	OFST-3,x
 981  8223               L163:
 984  8223 e602          	ldab	OFST-3,x
 985  8225 4f            	clra	
 986  8226 a30b          	subd	OFST+6,x
 987  8228 25c0          	blo	L553
 988                     ; 121 }
 991  822a ae00          	lds	0,x
 992  822c 38            	pulx	
 993  822d 39            	rts	
1016                     	switch	.bss
1017  2000               _erase:
1018  2000 0000          	ds.b	2
1019                     	xdef	_erase
1020                     	xdef	_EepromWrite
1021                     	xdef	_EepromByteWrite
1022                     	xdef	_EepromBulkErase
1023                     	xdef	_EepromErase
1024                     	xdef	_EepromInit
1025                     	xdef	_Delay
1026                     	xdef	_Init68hc11
1027                     	xref	c_kents
1028                     	end

⌨️ 快捷键说明

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