unsigned int eep_read(unsigned int adr)
{
volatile unsigned char tt[2];
volatile unsigned int x;
tt[0] = eeprom_read_byte(adr*2);
tt[1] = eeprom_read_byte(adr*2+1);
x = (unsigned int)tt[0]*256+tt[1];
return x;
}
void eep_write(unsigned int adr,unsigned int dat)
{
volatile unsigned char tt[2];
tt[0] = (unsigned char)(dat/256);
tt[1] = (unsigned char)(dat%256);
eeprom_write_byte(adr*2,tt[0]);
eeprom_write_byte(adr*2+1,tt[1]);
}
void E2p_init(void)
{
volatile unsigned int i,j;
volatile unsigned int te[30];
volatile unsigned char tt[2];
i = 0;
j = 0;
for(i=0;i<30;i++){
te[i] = eep_read(i);
}
for(i=0;i<30;i++)
te[i]=i*0x101;
for(i=0;i<30;i++){
eep_write(i, te[i]);
} for(i=0;i<30;i++)
te[i] = 0;
for(i=0;i<30;i++){
te[i] = eep_read(i);
}
}
E2p_init 程序里任意位置都不可以设断点,上面的子程序就可以
|