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

📄 stm8s_flash.ls

📁 STM8-触摸例程
💻 LS
📖 第 1 页 / 共 3 页
字号:
 722                     ; 334         StartAddress = FLASH_DATA_START_PHYSICAL_ADDRESS;
 724  00f9 ae4000        	ldw	x,#16384
 725  00fc               L772:
 726  00fc 1f03          	ldw	(OFST-3,sp),x
 727  00fe 5f            	clrw	x
 728  00ff 1f01          	ldw	(OFST-5,sp),x
 729                     ; 338     StartAddress = StartAddress + ((u32)BlockNum * FLASH_BLOCK_SIZE);
 731  0101 a680          	ld	a,#128
 732  0103 1e07          	ldw	x,(OFST+1,sp)
 733  0105 cd0000        	call	c_cmulx
 735  0108 96            	ldw	x,sp
 736  0109 5c            	incw	x
 737  010a cd0000        	call	c_lgadd
 739                     ; 341     if (ProgMode == FLASH_PROGRAMMODE_STANDARD)
 741  010d 7b0c          	ld	a,(OFST+6,sp)
 742  010f 260a          	jrne	L103
 743                     ; 344         FLASH->CR2 |= FLASH_CR2_PRG;
 745  0111 7210505b      	bset	20571,#0
 746                     ; 345         FLASH->NCR2 &= (u8)(~FLASH_NCR2_NPRG);
 748  0115 7211505c      	bres	20572,#0
 750  0119 2008          	jra	L303
 751  011b               L103:
 752                     ; 350         FLASH->CR2 |= FLASH_CR2_FPRG;
 754  011b 7218505b      	bset	20571,#4
 755                     ; 351         FLASH->NCR2 &= (u8)(~FLASH_NCR2_NFPRG);
 757  011f 7219505c      	bres	20572,#4
 758  0123               L303:
 759                     ; 355     for (Count = 0; Count < FLASH_BLOCK_SIZE; Count++)
 761  0123 5f            	clrw	x
 762  0124 1f05          	ldw	(OFST-1,sp),x
 763  0126               L503:
 764                     ; 357         *((u8*)StartAddress + Count) = ((u8)(Buffer[Count]));
 766  0126 1e0d          	ldw	x,(OFST+7,sp)
 767  0128 72fb05        	addw	x,(OFST-1,sp)
 768  012b f6            	ld	a,(x)
 769  012c 1e03          	ldw	x,(OFST-3,sp)
 770  012e 72fb05        	addw	x,(OFST-1,sp)
 771  0131 f7            	ld	(x),a
 772                     ; 355     for (Count = 0; Count < FLASH_BLOCK_SIZE; Count++)
 774  0132 1e05          	ldw	x,(OFST-1,sp)
 775  0134 5c            	incw	x
 776  0135 1f05          	ldw	(OFST-1,sp),x
 779  0137 a30080        	cpw	x,#128
 780  013a 25ea          	jrult	L503
 781                     ; 359 }
 784  013c 5b08          	addw	sp,#8
 785  013e 81            	ret	
 828                     ; 381 void FLASH_ProgramByte(u32 Address, u8 Data)
 828                     ; 382 {
 829                     	switch	.text
 830  013f               _FLASH_ProgramByte:
 832       00000000      OFST:	set	0
 835                     ; 384     assert_param(IS_FLASH_ADDRESS_OK(Address));
 837                     ; 387     *((@far u8*) Address) = Data;
 839  013f 7b07          	ld	a,(OFST+7,sp)
 840  0141 88            	push	a
 841  0142 7b05          	ld	a,(OFST+5,sp)
 842  0144 b700          	ld	c_x,a
 843  0146 1e06          	ldw	x,(OFST+6,sp)
 844  0148 bf01          	ldw	c_x+1,x
 845  014a 84            	pop	a
 846  014b 92bd0000      	ldf	[c_x.e],a
 847                     ; 391 }
 850  014f 81            	ret	
 895                     ; 411 void FLASH_ProgramOptionByte(u32 Address, u8 Data)
 895                     ; 412 {
 896                     	switch	.text
 897  0150               _FLASH_ProgramOptionByte:
 899       00000000      OFST:	set	0
 902                     ; 414     assert_param(IS_OPTION_BYTE_ADDRESS_OK(Address));
 904                     ; 417     FLASH->CR2 |= FLASH_CR2_OPT;
 906  0150 721e505b      	bset	20571,#7
 907                     ; 418     FLASH->NCR2 &= (u8)(~FLASH_NCR2_NOPT);
 909  0154 721f505c      	bres	20572,#7
 910                     ; 422     *((@far u8*)Address) = Data;
 912  0158 7b07          	ld	a,(OFST+7,sp)
 913  015a 88            	push	a
 914  015b 7b05          	ld	a,(OFST+5,sp)
 915  015d b700          	ld	c_x,a
 916  015f 1e06          	ldw	x,(OFST+6,sp)
 917  0161 bf01          	ldw	c_x+1,x
 918  0163 84            	pop	a
 919  0164 92bd0000      	ldf	[c_x.e],a
 920                     ; 423     *((@far u8*)(Address + 1)) = (u8)(~Data);
 922  0168 96            	ldw	x,sp
 923  0169 1c0003        	addw	x,#OFST+3
 924  016c cd0000        	call	c_ltor
 926  016f a601          	ld	a,#1
 927  0171 cd0000        	call	c_ladc
 929  0174 450100        	mov	c_x,c_lreg+1
 930  0177 be02          	ldw	x,c_lreg+2
 931  0179 bf01          	ldw	c_x+1,x
 932  017b 7b07          	ld	a,(OFST+7,sp)
 933  017d 43            	cpl	a
 934  017e 92bd0000      	ldf	[c_x.e],a
 935                     ; 429     FLASH_WaitForLastOperation(FLASH_MEMTYPE_DATA);
 937  0182 a601          	ld	a,#1
 938  0184 cd0294        	call	_FLASH_WaitForLastOperation
 940                     ; 432     FLASH->CR2 &= (u8)(~FLASH_CR2_OPT);
 942  0187 721f505b      	bres	20571,#7
 943                     ; 433     FLASH->NCR2 |= FLASH_NCR2_NOPT;
 945  018b 721e505c      	bset	20572,#7
 946                     ; 434 }
 949  018f 81            	ret	
 992                     ; 456 void FLASH_ProgramWord(u32 Address, u32 Data)
 992                     ; 457 {
 993                     	switch	.text
 994  0190               _FLASH_ProgramWord:
 996       00000000      OFST:	set	0
 999                     ; 459     assert_param(IS_FLASH_ADDRESS_OK(Address));
1001                     ; 462     FLASH->CR2 |= FLASH_CR2_WPRG;
1003  0190 721c505b      	bset	20571,#6
1004                     ; 463     FLASH->NCR2 &= (u8)(~FLASH_NCR2_NWPRG);
1006  0194 721d505c      	bres	20572,#6
1007                     ; 466     *((@far u8*)Address) = BYTE_0(Data); /* Write one byte */
1009  0198 7b0a          	ld	a,(OFST+10,sp)
1010  019a 88            	push	a
1011  019b 7b05          	ld	a,(OFST+5,sp)
1012  019d b700          	ld	c_x,a
1013  019f 1e06          	ldw	x,(OFST+6,sp)
1014  01a1 bf01          	ldw	c_x+1,x
1015  01a3 84            	pop	a
1016  01a4 92bd0000      	ldf	[c_x.e],a
1017                     ; 467     *(((@far u8*)Address) + 1) = BYTE_1(Data); /* Write one byte */
1019  01a8 7b09          	ld	a,(OFST+9,sp)
1020  01aa 88            	push	a
1021  01ab 7b05          	ld	a,(OFST+5,sp)
1022  01ad b700          	ld	c_x,a
1023  01af 1e06          	ldw	x,(OFST+6,sp)
1024  01b1 bf01          	ldw	c_x+1,x
1025  01b3 90ae0001      	ldw	y,#1
1026  01b7 93            	ldw	x,y
1027  01b8 84            	pop	a
1028  01b9 92a70000      	ldf	([c_x.e],x),a
1029                     ; 468     *(((@far u8*)Address) + 2) = BYTE_2(Data); /* Write one byte */
1031  01bd 7b08          	ld	a,(OFST+8,sp)
1032  01bf 88            	push	a
1033  01c0 7b05          	ld	a,(OFST+5,sp)
1034  01c2 b700          	ld	c_x,a
1035  01c4 1e06          	ldw	x,(OFST+6,sp)
1036  01c6 bf01          	ldw	c_x+1,x
1037  01c8 905c          	incw	y
1038  01ca 93            	ldw	x,y
1039  01cb 84            	pop	a
1040  01cc 92a70000      	ldf	([c_x.e],x),a
1041                     ; 469     *(((@far u8*)Address) + 3) = BYTE_3(Data); /* Write one byte */
1043  01d0 7b07          	ld	a,(OFST+7,sp)
1044  01d2 88            	push	a
1045  01d3 7b05          	ld	a,(OFST+5,sp)
1046  01d5 b700          	ld	c_x,a
1047  01d7 1e06          	ldw	x,(OFST+6,sp)
1048  01d9 bf01          	ldw	c_x+1,x
1049  01db 905c          	incw	y
1050  01dd 93            	ldw	x,y
1051  01de 84            	pop	a
1052  01df 92a70000      	ldf	([c_x.e],x),a
1053                     ; 476 }
1056  01e3 81            	ret	
1090                     ; 492 u8 FLASH_ReadByte(u32 Address)
1090                     ; 493 {
1091                     	switch	.text
1092  01e4               _FLASH_ReadByte:
1094       00000000      OFST:	set	0
1097                     ; 495     assert_param(IS_FLASH_ADDRESS_OK(Address));
1099                     ; 498     return(*((@far u8*) Address)); /* Read byte */
1101  01e4 7b04          	ld	a,(OFST+4,sp)
1102  01e6 b700          	ld	c_x,a
1103  01e8 1e05          	ldw	x,(OFST+5,sp)
1104  01ea bf01          	ldw	c_x+1,x
1105  01ec 92bc0000      	ldf	a,[c_x.e]
1108  01f0 81            	ret	
1171                     ; 518 u16 FLASH_ReadOptionByte(u32 Address)
1171                     ; 519 {
1172                     	switch	.text
1173  01f1               _FLASH_ReadOptionByte:
1175  01f1 5204          	subw	sp,#4
1176       00000004      OFST:	set	4
1179                     ; 520     u8 value_optbyte, value_optbyte_complement = 0;
1181                     ; 521     u16 res_value = 0;
1183                     ; 524     assert_param(IS_OPTION_BYTE_ADDRESS_OK(Address));
1185                     ; 527     value_optbyte = *((@far u8*)Address); /* Read option byte */
1187  01f3 7b08          	ld	a,(OFST+4,sp)
1188  01f5 b700          	ld	c_x,a
1189  01f7 1e09          	ldw	x,(OFST+5,sp)
1190  01f9 bf01          	ldw	c_x+1,x
1191  01fb 92bc0000      	ldf	a,[c_x.e]
1192  01ff 6b01          	ld	(OFST-3,sp),a
1193                     ; 528     value_optbyte_complement = *(((@far u8*)Address) + 1); /* Read option byte complement*/
1195  0201 90ae0001      	ldw	y,#1
1196  0205 93            	ldw	x,y
1197  0206 92af0000      	ldf	a,([c_x.e],x)
1198  020a 6b02          	ld	(OFST-2,sp),a
1199                     ; 534     if (value_optbyte == (u8)(~value_optbyte_complement))
1201  020c 43            	cpl	a
1202  020d 1101          	cp	a,(OFST-3,sp)
1203  020f 2614          	jrne	L154
1204                     ; 536         res_value = (u16)((u16)value_optbyte << 8);
1206  0211 7b01          	ld	a,(OFST-3,sp)
1207  0213 97            	ld	xl,a
1208  0214 4f            	clr	a
1209  0215 02            	rlwa	x,a
1210  0216 1f03          	ldw	(OFST-1,sp),x
1211                     ; 537         res_value = res_value | (u16)value_optbyte_complement;
1213  0218 5f            	clrw	x
1214  0219 7b02          	ld	a,(OFST-2,sp)
1215  021b 97            	ld	xl,a
1216  021c 01            	rrwa	x,a
1217  021d 1a04          	or	a,(OFST+0,sp)
1218  021f 01            	rrwa	x,a
1219  0220 1a03          	or	a,(OFST-1,sp)
1220  0222 01            	rrwa	x,a
1222  0223 2003          	jra	L354

⌨️ 快捷键说明

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