main.c
来自「avr单片机的一些实际应用源码」· C语言 代码 · 共 34 行
C
34 行
/*
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 + =
减小字号Ctrl + -
显示快捷键?