| 东哥单片机学习网 推荐:[交流论坛] 交流单片机开发的好去处 | 加入收藏 网站地图 网站搜索 |
|
| 您的位置:首页 → 单片机 → AVR单片机 |
|
阅读内容
背景:
AVR单片机读写EEPROM子程序
void EEPROM_write(unsigned int uiAddress, unsigned char ucData) { /* 等待上一次写操作结束 */ while(EECR & (1<<EEWE)) ; /* 设置地址和数据寄存器*/ EEAR = uiAddress; EEDR = ucData; /* 置位EEMWE */ EECR |= (1<<EEMWE); /* 置位EEWE 以启动写操作*/ EECR |= (1<<EEWE); } unsigned char EEPROM_read(unsigned int uiAddress) { /* 等待上一次写操作结束 */ while(EECR & (1<<EEWE)) ; /* 设置地址寄存器*/ EEAR = uiAddress; /* 设置EERE 以启动读操作*/ EECR |= (1<<EERE); /* 自数据寄存器返回数据 */ return EEDR; } void EEPROM_read_block(unsigned char *store_point, unsigned int _uiAddress,unsigned char n) { unsigned char i; //unsigned int x1; //unsigned char x2; for(i=0;i<n;i++) { //x2=EEPROM_read(_uiAddress); //_uiAddress++; //x1=EEPROM_read(_uiAddress); //x1<<8; //x1=x1+x2; //* store_point=x1; * store_point=EEPROM_read(_uiAddress); store_point++; _uiAddress++; } }
发表评论
|
赞助商广告
|