void WriteEE(unsigned char adds,unsigned char data)
{
while(WR==1); //上一次写操作是否完成
EEADR=adds; //EEPROM地址
EEDAT=data; //准备写入EEPROM的数据
EEPGD=0; //指向EEPROM数据储存器
CFGS=0; //指向EEPROM数据储存器
WREN=1; //使能写操作
GIE=0; //禁止中断
EECON2=0x55;
EECON2=0xAA; //EEPROM解锁
WR=1;
GIE=1; //开始写
while(WR==1); //等待写操作完成
if(EEIF==1)
EEIF=0;
WREN=0; //禁止写操作
}
unsigned char ReadEE(unsigned char adds)
{
unsigned char num;
while(RD==1); //上一次读操作是否完成
EEADR=adds; //EEPROM地址为00H
EEPGD=0; //指向EEPROM数据储存器
CFGS=0; //指向EEPROM数据储存器
RD=1; //开始读
while(RD==1); //等待读操作完成
num=EEDAT; //读出
return(num); //返回读出的数
}
void write_eeprom(unsigned char data, unsigned char add )
{
//while(WR==1);
EEADR=add;
EEDAT=data; //欲写入之数据
EEPGD=0x00; //操作数据EEPROM区
WREN=0x01; //使能写操作
GIE=0x00; //禁止中断
EECON2=0x55;
EECON2=0xAA;
WR=0x01;
GIE=0x01;
// delay(0x02);
while(WR==1);
if(EEIF==1)
EEIF=0;
WREN=0x00;
}
unsigned char read_eeprom(unsigned add)
{ unsigned char num;
while(RD==1);
EEADR=add; //寻址地址
EEPGD=0x00; //操作数据EEPROM区
RD=0x01; //启动读操作
// return EEDAT;
while(RD==1); //等待读操作完成
num=EEDAT; //读出
return(num);
}
初始化
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
设计资源 培训 开发板 精华推荐
- 2.5V 输出 ADR391B 微功耗、低噪声精密电压基准的典型应用
- LT8330IDDB 8V 至 16V 输入、24V 升压转换器的典型应用电路
- LTC3245HMSE 降压-升压型电荷泵稳压 5V 低噪声输出的典型应用电路
- LT3470、低纹波微功率 SOT-23 降压稳压器,具有集成升压和捕捉二极管,接受 40V 输入
- ADC120 8通道,50ksps至1Msps,12位模数转换器的评估板
- MAXREFDES9000:基于DS28E18的远程两线供电及控制I2C和SPI接口传感器
- FRDM-17531EV-EVB: Freedom扩展板 - MPC17531A,双H桥,步进电机驱动器,2.0V-8.6V,0.7A
- MIC29201-5.0WU 400mA低压降稳压器典型应用
- 用于白色家电的 20 至 25W、12V 交流至直流单路输出电源
- VG7050ECN-EVB、VG7050ECN 评估板,通过 I2C 总线设置寄存器