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

📄 rteeprom.s

📁 AVR系列单片机ATMEGA64开发的LED显示屏程序 内容包括ATMEGA64大部分资源的初始化程序
💻 S
字号:
	.module rteeprom.c
	.area text(rom, con, rel)
	.dbfile C:\DOCUME~1\11111\桌面\13个费显MEGA64\重显MEGA64\rteeprom.c
	.dbfunc e RTEEPROMReady _RTEEPROMReady fc
	.even
_RTEEPROMReady::
	.dbline -1
	.dbline 5
; #include <include.h>
; // function to test if the EEPROM is ready for a read or write operation
; // returns non zero if ready, zero if not ready 
; unsigned char RTEEPROMReady(void)
; {
	.dbline 6
; 	return !(EECR & 0x02);
	sbic 0x1c,1
	rjmp L3
	ldi R16,1
	ldi R17,0
	xjmp L4
L3:
	clr R16
	clr R17
L4:
	.dbline -2
L2:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e RTEEPROMwrite _RTEEPROMwrite fV
;      savedSREG -> R20
;       databyte -> R20
;       location -> R22,R23
	.even
_RTEEPROMwrite::
	xcall push_gset2
	mov R20,R18
	movw R22,R16
	.dbline -1
	.dbline 15
; }
; 
; 
; 
; // function to initiate an EEPROM write
; // writes the specified data byte to the specified location
; // this will fail if the EEPROM is not ready!
; void RTEEPROMwrite(int location, unsigned char databyte)
; {
	.dbline 17
; 	unsigned char savedSREG;
; 	EEAR = location;								// set address
	out 0x1f,R23
	out 0x1e,R22
	.dbline 18
; 	EEDR = databyte;								// set data	
	out 0x1d,R20
	.dbline 19
; 	savedSREG = SREG;								// keep setting so it can be restored
	in R20,0x3f
	.dbline 20
; 	CLI();													// disable interrupts
	cli
	.dbline 21
; 	EECR |= BIT(EEMWE);							// set "write enable" bit
	sbi 0x1c,2
	.dbline 22
; 	EECR |= BIT(EEWE);							// set "write" bit
	sbi 0x1c,1
	.dbline 23
; 	SREG = savedSREG;								// restore SREG
	out 0x3f,R20
	.dbline 24
; 	EEAR = 0;
	clr R2
	clr R3
	out 0x1f,R3
	out 0x1e,R2
L6:
	.dbline 25
L7:
	.dbline 25
; 	while(!RTEEPROMReady());
	xcall _RTEEPROMReady
	tst R16
	breq L6
	.dbline -2
L5:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r savedSREG 20 c
	.dbsym r databyte 20 c
	.dbsym r location 22 I
	.dbend
	.dbfunc e RTEEPROMread _RTEEPROMread fc
;       location -> R16,R17
	.even
_RTEEPROMread::
	.dbline -1
	.dbline 34
; }
; 
; 
; 
; // function to read from the EEPROM
; // reads a byte from the specified location
; // this will fail if the EEPROM is not ready!
; unsigned char RTEEPROMread(int location)
; {
	.dbline 35
; 	EEAR = location;								// set address
	out 0x1f,R17
	out 0x1e,R16
	.dbline 36
; 	EECR |= BIT(EERE);							// set "read enable" bit
	sbi 0x1c,0
	.dbline 37
; 	EEAR = 0;
	clr R2
	clr R3
	out 0x1f,R3
	out 0x1e,R2
	.dbline 38
; 	return (EEDR);
	in R16,0x1d
	.dbline -2
L9:
	.dbline 0 ; func end
	ret
	.dbsym r location 16 I
	.dbend

⌨️ 快捷键说明

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