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

📄 rteeprom.c

📁 AVR系列单片机ATMEGA64开发的LED显示屏程序 内容包括ATMEGA64大部分资源的初始化程序
💻 C
字号:
#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)
{
	return !(EECR & 0x02);
}



// 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)
{
	unsigned char savedSREG;
	EEAR = location;								// set address
	EEDR = databyte;								// set data	
	savedSREG = SREG;								// keep setting so it can be restored
	CLI();													// disable interrupts
	EECR |= BIT(EEMWE);							// set "write enable" bit
	EECR |= BIT(EEWE);							// set "write" bit
	SREG = savedSREG;								// restore SREG
	EEAR = 0;
	while(!RTEEPROMReady());
}



// 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)
{
	EEAR = location;								// set address
	EECR |= BIT(EERE);							// set "read enable" bit
	EEAR = 0;
	return (EEDR);
}

⌨️ 快捷键说明

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