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

📄 main.c

📁 关于学习avr单片机的资料
💻 C
字号:
/*
	avr-libc EEPROM 读写测试程序 <2313-2>
	main.c
	MCU:at90s2313  
	
	芯艺 2004-09-11
*/

#include <avr/io.h>
#include <avr/eeprom.h>

#define SET_LED PORTD=0X10;//PD4接有LED

char val1 __attribute__((section(".eeprom")))=0xaa;
char val2[] __attribute__((section(".eeprom")))="hello,this is test eeprom";

int main(void)
{
	DDRD=0X10;
	PORTD=0X00;
	
	eeprom_busy_wait();
	eeprom_write_byte(&val1,0xaa);
	eeprom_busy_wait();
	eeprom_write_block("hello,this is test eeprom",val2,sizeof("hello,this is test eeprom"));
	
	eeprom_busy_wait();
	if(eeprom_read_byte(&val1)==0xaa)
		SET_LED;
		
	while(1);
	return 0;
}

⌨️ 快捷键说明

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