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

📄 eeprom.s

📁 ATmega16应用例子
💻 S
字号:
	.module EEPROM.C
	.area text(rom, con, rel)
	.dbfile E:\ICCAVR_H\CmmICC.H
	.dbfunc e delay50us _delay50us fV
;              j -> R20
;              t -> R16,R17
	.even
_delay50us::
	xcall push_gset1
	.dbline -1
	.dbline 115
; #include<iom16v.h>
; #include "E:\ICCAVR_H\CmmICC.H"
; 
; 
; void main(void) 
; {
;  uint8 i;
;  sint16 wrDat=0x55;
;  uint8 wrDat_[]={1,2,3,4,5,6,7,8},rdDat_[8];
;  DDRD=0xFF;
;  EEPROMwrite(0x01,wrDat);
;  PORTD=EEPROMread(0x01);	
;  delay50ms(20);			
;  EEPROMWriteBytes(1,wrDat_,8);
;  EEPROMReadBytes(1,rdDat_,8);
;  for(i=0;i<7;i++)
;  {
;  delay50ms(20);	
;   PORTD=rdDat_[i];
;   } 			
;  while(1);
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
	.dbline 117
; }
; }
	xjmp L5
L2:
	.dbline 118
; }
	clr R20
	xjmp L9
L6:
	.dbline 119
L7:
	.dbline 118
	inc R20
L9:
	.dbline 118
	cpi R20,70
	brlo L6
L3:
	.dbline 117
	subi R16,1
	sbci R17,0
L5:
	.dbline 117
	clr R2
	clr R3
	cp R2,R16
	cpc R3,R17
	brlt L2
	.dbline -2
	.dbline 120
; }
; }
L1:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r j 20 c
	.dbsym r t 16 I
	.dbend
	.dbfunc e delay50ms _delay50ms fV
;              i -> R20,R21
;              t -> R16,R17
	.even
_delay50ms::
	xcall push_gset1
	.dbline -1
	.dbline 130
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
	.dbline 132
; }
; }
	xjmp L14
L11:
	.dbline 133
; }
	clr R20
	clr R21
	xjmp L18
L15:
	.dbline 134
L16:
	.dbline 133
	subi R20,255  ; offset = 1
	sbci R21,255
L18:
	.dbline 133
	cpi R20,162
	ldi R30,205
	cpc R21,R30
	brlo L15
L12:
	.dbline 132
	subi R16,1
	sbci R17,0
L14:
	.dbline 132
	clr R2
	clr R3
	cp R2,R16
	cpc R3,R17
	brlt L11
	.dbline -2
	.dbline 135
; }
; }
L10:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r i 20 i
	.dbsym r t 16 I
	.dbend
	.dbfunc e speaData _speaData fV
;              y -> y+4
;              j -> y+0
;              i -> R10
;              C -> R12
;              D -> y+16
	.even
_speaData::
	xcall push_arg4
	xcall push_gset4
	sbiw R28,8
	ldd R12,y+20
	.dbline -1
	.dbline 146
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
	.dbline 149
; }
; }
; }
	clr R10
	ldi R20,1
	ldi R21,0
	ldi R22,0
	ldi R23,0
	movw R30,R28
	std z+0,R20
	std z+1,R21
	std z+2,R22
	std z+3,R23
	xjmp L23
L20:
	.dbline 150
	.dbline 151
	movw R30,R28
	ldd R2,z+0
	ldd R3,z+1
	ldd R4,z+2
	ldd R5,z+3
	movw R30,R28
	ldd R6,z+16
	ldd R7,z+17
	ldd R8,z+18
	ldd R9,z+19
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R16,R6
	movw R18,R8
	xcall div32u
	movw R30,R28
	std z+4,R16
	std z+5,R17
	std z+6,R18
	std z+7,R19
	.dbline 152
	ldi R20,10
	ldi R21,0
	ldi R22,0
	ldi R23,0
	movw R30,R28
	ldd R2,z+4
	ldd R3,z+5
	ldd R4,z+6
	ldd R5,z+7
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	movw R16,R2
	movw R18,R4
	xcall mod32u
	ldi R24,<_dataElem
	ldi R25,>_dataElem
	mov R30,R10
	clr R31
	add R30,R24
	adc R31,R25
	std z+0,R16
	.dbline 153
	movw R30,R28
	ldd R2,z+0
	ldd R3,z+1
	ldd R4,z+2
	ldd R5,z+3
	ldi R20,10
	ldi R21,0
	ldi R22,0
	ldi R23,0
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R16,R20
	movw R18,R22
	xcall empy32u
	movw R30,R28
	std z+0,R16
	std z+1,R17
	std z+2,R18
	std z+3,R19
	.dbline 154
L21:
	.dbline 149
	inc R10
L23:
	.dbline 149
	cp R10,R12
	brsh X0
	xjmp L20
X0:
	.dbline -2
	.dbline 155
; }
; }
; }
; }
; }
; }
L19:
	adiw R28,8
	xcall pop_gset4
	adiw R28,4
	.dbline 0 ; func end
	ret
	.dbsym l y 4 l
	.dbsym l j 0 l
	.dbsym r i 10 c
	.dbsym r C 12 c
	.dbsym l D 16 l
	.dbend
	.dbfunc e changeDToH _changeDToH fc
;            hex -> R20
;              t -> y+0
;            dec -> R20
	.even
_changeDToH::
	xcall push_gset1
	mov R20,R16
	sbiw R28,2
	.dbline -1
	.dbline 165
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
	.dbline 168
; }
; }
; }
	ldi R17,10
	mov R16,R20
	xcall div8u
	std y+1,R16
	.dbline 169
; }
	ldi R17,10
	mov R16,R20
	xcall mod8u
	std y+0,R16
	.dbline 170
; }
	ldd R2,y+1
	ldi R24,16
	mul R24,R2
	mov R20,R0
	add R20,R16
	.dbline 171
; }
	mov R16,R20
	.dbline -2
L24:
	adiw R28,2
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r hex 20 c
	.dbsym l t 0 A[2:2]c
	.dbsym r dec 20 c
	.dbend
	.dbfunc e converseDToH _converseDToH fc
;            hex -> R20
;              t -> y+0
;            dec -> R20
	.even
_converseDToH::
	xcall push_gset1
	mov R20,R16
	sbiw R28,2
	.dbline -1
	.dbline 182
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
	.dbline 185
; }
; }
; }
	mov R24,R20
	swap R24
	andi R24,#0x0F
	std y+1,R24
	.dbline 186
; }
	ldi R17,16
	mov R16,R20
	xcall mod8u
	std y+0,R16
	.dbline 187
; }
	ldd R2,y+1
	ldi R24,16
	mul R24,R2
	mov R20,R0
	add R20,R16
	.dbline 188
; }
	mov R16,R20
	.dbline -2
L27:
	adiw R28,2
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r hex 20 c
	.dbsym l t 0 A[2:2]c
	.dbsym r dec 20 c
	.dbend
	.dbfunc e changeHToD _changeHToD fc
;            dec -> R20
;              t -> y+0
;            hex -> R20
	.even
_changeHToD::
	xcall push_gset1
	mov R20,R16
	sbiw R28,2
	.dbline -1
	.dbline 199
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
	.dbline 202
; }
; }
; }
	mov R24,R20
	swap R24
	andi R24,#0x0F
	std y+1,R24
	.dbline 203
; }
	ldi R17,16
	mov R16,R20
	xcall mod8u
	std y+0,R16
	.dbline 204
; }
	ldd R2,y+1
	ldi R24,10
	mul R24,R2
	mov R20,R0
	add R20,R16
	.dbline 205
; }
	mov R16,R20
	.dbline -2
L30:
	adiw R28,2
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r dec 20 c
	.dbsym l t 0 A[2:2]c
	.dbsym r hex 20 c
	.dbend
	.dbfunc e converseHToD _converseHToD fc
;            dec -> R20
;              t -> y+0
;            hex -> R20
	.even
_converseHToD::
	xcall push_gset1
	mov R20,R16
	sbiw R28,2
	.dbline -1
	.dbline 216
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
	.dbline 219
; }
; }
; }
	ldi R17,10
	mov R16,R20
	xcall div8u
	std y+1,R16
	.dbline 220
; }
	ldi R17,10
	mov R16,R20
	xcall mod8u
	std y+0,R16
	.dbline 221
; }
	ldd R2,y+1
	ldi R24,16
	mul R24,R2
	mov R20,R0
	add R20,R16
	.dbline 222
; }
	mov R16,R20
	.dbline -2
L33:
	adiw R28,2
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r dec 20 c
	.dbsym l t 0 A[2:2]c
	.dbsym r hex 20 c
	.dbend
	.area lit(rom, con, rel)
L37:
	.byte 1,2
	.byte 3,4
	.byte 5,6
	.byte 7,8
	.area text(rom, con, rel)
	.dbfile E:\ICCAVR_H\CmmICC.H
	.dbfile E:\ProductPro\M16SD\ICCAVR\EEPROM\EEPROM\EEPROM.C
	.dbfunc e main _main fV
;         wrDat_ -> y+10
;          wrDat -> R20,R21
;         rdDat_ -> y+2
;              i -> R20
	.even
_main::
	sbiw R28,18
	.dbline -1
	.dbline 6
	.dbline 8
	ldi R20,85
	ldi R21,0
	.dbline 9
	ldi R24,<L37
	ldi R25,>L37
	movw R30,R28
	adiw R30,10
	ldi R16,8
	ldi R17,0
	st -y,R31
	st -y,R30
	st -y,R25
	st -y,R24
	xcall asgncblk
	.dbline 10
	ldi R24,255
	out 0x11,R24
	.dbline 11
	movw R18,R20
	ldi R16,1
	ldi R17,0
	xcall _EEPROMwrite
	.dbline 12
	ldi R16,1
	ldi R17,0
	xcall _EEPROMread
	out 0x12,R16
	.dbline 13
	ldi R16,20
	ldi R17,0
	xcall _delay50ms
	.dbline 14
	ldi R24,8
	ldi R25,0
	std y+1,R25
	std y+0,R24
	movw R18,R28
	subi R18,246  ; offset = 10
	sbci R19,255
	ldi R16,1
	ldi R17,0
	xcall _EEPROMWriteBytes
	.dbline 15
	ldi R24,8
	ldi R25,0
	std y+1,R25
	std y+0,R24
	movw R18,R28
	subi R18,254  ; offset = 2
	sbci R19,255
	ldi R16,1
	ldi R17,0
	xcall _EEPROMReadBytes
	.dbline 16
	clr R20
	xjmp L41
L38:
	.dbline 17
	.dbline 18
	ldi R16,20
	ldi R17,0
	xcall _delay50ms
	.dbline 19
	movw R24,R28
	adiw R24,2
	mov R30,R20
	clr R31
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	out 0x12,R2
	.dbline 20
L39:
	.dbline 16
	inc R20
L41:
	.dbline 16
	cpi R20,7
	brlo L38
L42:
	.dbline 21
L43:
	.dbline 21
	xjmp L42
X1:
	.dbline -2
	.dbline 22
L36:
	adiw R28,18
	.dbline 0 ; func end
	ret
	.dbsym l wrDat_ 10 A[8:8]c
	.dbsym r wrDat 20 I
	.dbsym l rdDat_ 2 A[8:8]c
	.dbsym r i 20 c
	.dbend
	.area bss(ram, con, rel)
	.dbfile E:\ProductPro\M16SD\ICCAVR\EEPROM\EEPROM\EEPROM.C
_dataElem::
	.blkb 6
	.dbfile E:\ICCAVR_H\CmmICC.H
	.dbsym e dataElem _dataElem A[6:6]c

⌨️ 快捷键说明

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