//EEPROM READ&&WRITE FUNCTION
//1.不管是宏定义里面写EEPROM和函数内部写EEPROM的数据,都能通过调试器读出数据
//2.建议在写EEPROM以后不要立即读其数据,要延时一段时间
//3.跟IDLOC类似,EEPROM_DATA宏定义也会拆数据。觉得还是函数比较实用
//4.16F877A有00-FF 128个字节存储单元
#include <pic.h>
#define uchar unsigned char
#define uint unsigned int
uchar temp="0";
uchar i="0";
uint count="0";
__CONFIG(0x3B32);
__EEPROM_DATA(0,1,2,3,4,5,6,7);
__EEPROM_DATA(0,1,2,3,4,5,6,7);
__IDLOC(1234);
void Delay(uchar time)
{
uchar x,y,z;
for(x=time;x>0;x--)
for(y=0;y<20;y++)
for(z=0;z<248;z++);
}
void main()
{
TRISD=0;
PORTD=0XFF;
while(1)
{
EEPROM_WRITE(0X21,0XFA);
temp=EEPROM_READ(0X21);
EEPROM_WRITE(0X22,temp);
PORTD=temp;
while(1);
}
}
文章评论(0条评论)
登录后参与讨论