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

📄 eeprom.ls

📁 使用单片机mc68hc11f1对内部EEprom擦除的程序
💻 LS
字号:
   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  0000               _Init68hc11:
 464  0000 3c            	pshx	
 467                     ; 10 INIT=0X21;//寄存器,RAM空间映像,01为复位值
 469  0001 c621          	ldab	#33
 470  0003 ce1000        	ldx	#4096
 471  0006 e73d          	stab	61,x
 472                     ; 15 CSCTL|=0x21;//64k
 474  0008 1c5d21        	bset	93,x,#33
 475                     ; 16 CSGSIZ|=0X40;
 477  000b 1c5f40        	bset	95,x,#64
 478                     ; 17 CSSTRH|=0x30;
 480  000e 1c5c30        	bset	92,x,#48
 481                     ; 19 }
 484  0011 38            	pulx	
 485  0012 39            	rts	
 536                     ; 21 void Delay(uchar n)
 536                     ; 22 {uchar i,j,k;
 537                     	switch	.text
 538  0013               _Delay:
 540  0013 bd0000        	jsr	c_kents
 541  0016 05            	dc.b	5
 542       00000005      OFST:	set	5
 545                     ; 24 	  for(i=0;i<n;i++)
 547  0017 6f04          	clr	OFST-1,x
 549  0019 2024          	bra	L732
 550  001b               L332:
 551                     ; 25 	  {		for (j=0;j<200;j++)
 553  001b 6f03          	clr	OFST-2,x
 554  001d               L342:
 555                     ; 26 		  {		for (k=0;k<10;k++)
 557  001d 6f02          	clr	OFST-3,x
 558  001f               L152:
 562  001f 6c02          	inc	OFST-3,x
 565  0021 e602          	ldab	OFST-3,x
 566  0023 c10a          	cmpb	#10
 567  0025 25f8          	blo	L152
 568                     ; 29 			COPRST=0X55;
 570  0027 c655          	ldab	#85
 571  0029 18ce1000      	ldy	#4096
 572  002d 18e73a        	stab	58,y
 573                     ; 30 			COPRST=0XAA;  
 575  0030 c6aa          	ldab	#170
 576  0032 18e73a        	stab	58,y
 577                     ; 25 	  {		for (j=0;j<200;j++)
 579  0035 6c03          	inc	OFST-2,x
 582  0037 e603          	ldab	OFST-2,x
 583  0039 c1c8          	cmpb	#200
 584  003b 25e0          	blo	L342
 585                     ; 24 	  for(i=0;i<n;i++)
 587  003d 6c04          	inc	OFST-1,x
 588  003f               L732:
 591  003f e604          	ldab	OFST-1,x
 592  0041 e106          	cmpb	OFST+1,x
 593  0043 25d6          	blo	L332
 594                     ; 34 }
 597  0045 ae00          	lds	0,x
 598  0047 38            	pulx	
 599  0048 39            	rts	
 620                     ; 36 void EepromInit(void)
 620                     ; 37 {
 621                     	switch	.text
 622  0049               _EepromInit:
 624  0049 3c            	pshx	
 627                     ; 40 PPROG=0X00;//复位时:00
 629  004a 5f            	clrb	
 630  004b ce1000        	ldx	#4096
 631  004e e73b          	stab	59,x
 632                     ; 41 }
 635  0050 38            	pulx	
 636  0051 39            	rts	
 670                     ; 42 void EepromErase(uchar *addr)
 670                     ; 43 {//erase=(volatile unsigned char*)(0xfe00);
 671                     	switch	.text
 672  0052               _EepromErase:
 674  0052 3c            	pshx	
 675                     	pshd	
 676  0055 30            	tsx	
 677       00000000      OFST:	set	0
 680                     ; 45  erase=((volatile unsigned char*)(addr));
 682  0056 ec00          	ldd	OFST+0,x
 683  0058 fd0000        	std	_erase
 684                     ; 48 {PPROG=0X16;//擦除方式 块擦除
 686  005b c616          	ldab	#22
 687  005d 18ce1000      	ldy	#4096
 688  0061 18e73b        	stab	59,y
 689                     ; 49 (*erase)=0xff;
 691  0064 c6ff          	ldab	#255
 692  0066 18fe0000      	ldy	_erase
 693  006a 18e700        	stab	0,y
 694                     ; 51 PPROG=0X17;//打开编程电源
 696  006d c617          	ldab	#23
 697  006f 18ce1000      	ldy	#4096
 698  0073 18e73b        	stab	59,y
 699                     ; 52 Delay(100);//延时10Ms
 701  0076 cc0064        	ldd	#100
 702  0079 8d98          	jsr	_Delay
 704                     ; 53 PPROG=0X00;//置为读出方式
 706  007b 5f            	clrb	
 707  007c 18ce1000      	ldy	#4096
 708  0080 18e73b        	stab	59,y
 709                     ; 55 }
 712  0083 38            	pulx	
 713  0084 38            	pulx	
 714  0085 39            	rts	
 736                     ; 57 void EepromBulkErase(void)
 736                     ; 58 {uchar *i;
 737                     	switch	.text
 738  0086               _EepromBulkErase:
 740  0086 3c            	pshx	
 743                     ; 59 PPROG=0X06;//擦除方式
 745  0087 c606          	ldab	#6
 746  0089 ce1000        	ldx	#4096
 747  008c e73b          	stab	59,x
 748                     ; 64 EEPROMBASEADDRESS=0xdd;
 750  008e c6dd          	ldab	#221
 751  0090 f70e00        	stab	3584
 752                     ; 66 PPROG=0X07;//打开编程电源
 754  0093 c607          	ldab	#7
 755  0095 e73b          	stab	59,x
 756                     ; 67 Delay(100);//延时10Ms
 758  0097 cc0064        	ldd	#100
 759  009a bd0013        	jsr	_Delay
 761                     ; 68 PPROG=0X00;//置为读出方式
 763  009d 5f            	clrb	
 764  009e ce1000        	ldx	#4096
 765  00a1 e73b          	stab	59,x
 766                     ; 83 }
 769  00a3 38            	pulx	
 770  00a4 39            	rts	
 811                     ; 87 void EepromByteWrite(uchar *aimaddr,uchar a)
 811                     ; 88 { //uchar *i;
 812                     	switch	.text
 813  00a5               _EepromByteWrite:
 815  00a5 3c            	pshx	
 816                     	pshd	
 817  00a8 30            	tsx	
 818       00000000      OFST:	set	0
 821                     ; 90 	erase=(aimaddr);
 823  00a9 ec00          	ldd	OFST+0,x
 824  00ab fd0000        	std	_erase
 825                     ; 91 	PPROG=0X02;//允许锁存地址和数据
 827  00ae c602          	ldab	#2
 828  00b0 18ce1000      	ldy	#4096
 829  00b4 18e73b        	stab	59,y
 830                     ; 92 	(*erase)=a;
 832  00b7 e607          	ldab	OFST+7,x
 833  00b9 18fe0000      	ldy	_erase
 834  00bd 18e700        	stab	0,y
 835                     ; 93 	PPROG=0X03;//加编程电压
 837  00c0 c603          	ldab	#3
 838  00c2 18ce1000      	ldy	#4096
 839  00c6 18e73b        	stab	59,y
 840                     ; 94 	Delay(20);//10ms
 842  00c9 cc0014        	ldd	#20
 843  00cc bd0013        	jsr	_Delay
 845                     ; 95 	PPROG=0X00;//清除
 847  00cf 5f            	clrb	
 848  00d0 18ce1000      	ldy	#4096
 849  00d4 18e73b        	stab	59,y
 850                     ; 98 }
 853  00d7 38            	pulx	
 854  00d8 38            	pulx	
 855  00d9 39            	rts	
 920                     ; 100 void EepromWrite(uchar *aimaddr,uint number,uchar *source)
 920                     ; 101 { uchar i=0;
 921                     	switch	.text
 922  00da               _EepromWrite:
 924  00da bd0000        	jsr	c_kents
 925  00dd 05            	dc.b	5
 926       00000005      OFST:	set	5
 931  00de 6f02          	clr	OFST-3,x
 932                     ; 103 j=(volatile unsigned char*)(aimaddr);
 934  00e0 ec05          	ldd	OFST+0,x
 935  00e2 ed03          	std	OFST-2,x
 936                     ; 106 			for(i=0;i<(number);i++)						   //写入数据EEprom
 938  00e4 6f02          	clr	OFST-3,x
 940  00e6 2039          	bra	L163
 941  00e8               L553:
 942                     ; 107 				{PPROG=0X02;//允许锁存地址和数据
 944  00e8 c602          	ldab	#2
 945  00ea 18ce1000      	ldy	#4096
 946  00ee 18e73b        	stab	59,y
 947                     ; 108 					(*j)=(*source);
 949  00f1 1aee0d        	ldy	OFST+8,x
 950  00f4 18e600        	ldab	0,y
 951  00f7 1aee03        	ldy	OFST-2,x
 952  00fa 18e700        	stab	0,y
 953                     ; 110 					source++;
 955  00fd 6c0e          	inc	OFST+9,x
 956  00ff 2602          	bne	L02
 957  0101 6c0d          	inc	OFST+8,x
 958  0103               L02:
 959                     ; 111 					j++;
 961  0103 1808          	iny	
 962  0105 1aef03        	sty	OFST-2,x
 963                     ; 112 					PPROG=0X03;//加编程电压
 965  0108 c603          	ldab	#3
 966  010a 18ce1000      	ldy	#4096
 967  010e 18e73b        	stab	59,y
 968                     ; 117 				Delay(2);//10ms
 970  0111 cc0002        	ldd	#2
 971  0114 bd0013        	jsr	_Delay
 973                     ; 118 				PPROG=0X00;//清除
 975  0117 5f            	clrb	
 976  0118 18ce1000      	ldy	#4096
 977  011c 18e73b        	stab	59,y
 978                     ; 106 			for(i=0;i<(number);i++)						   //写入数据EEprom
 980  011f 6c02          	inc	OFST-3,x
 981  0121               L163:
 984  0121 e602          	ldab	OFST-3,x
 985  0123 4f            	clra	
 986  0124 a30b          	subd	OFST+6,x
 987  0126 25c0          	blo	L553
 988                     ; 121 }
 991  0128 ae00          	lds	0,x
 992  012a 38            	pulx	
 993  012b 39            	rts	
1016                     	switch	.bss
1017  0000               _erase:
1018  0000 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 + -