//該值可以為小數(shù)#define GapValue 349
volatile bit ClearWeighFlag = 0; //傳感器調(diào)零標志位,清除0漂
/******************把數(shù)據(jù)保存到單片機內(nèi)部eeprom中******************/
void write_eeprom()
{
SectorErase(0x1000);
GapValue1=GapValue&0x00ff;
byte_write(0x2000, GapValue1);
GapValue1=(GapValue&0xff00)>>8;
byte_write(0x2001, GapValue1);
byte_write(0x2060, a_a);
}
/******************把數(shù)據(jù)從單片機內(nèi)部eeprom中讀出來*****************/
void read_eeprom()
{
GapValue = byte_read(0x2001);
GapValue = (GapValue<<8)|byte_read(0x2000);
a_a = byte_read(0x2060);
}
/**************開機自檢eeprom初始化*****************/
void init_eeprom()
{
read_eeprom(); //先讀
if(a_a != 1) //新的單片機初始單片機內(nèi)問eeprom
{
GapValue = 349+140*5+2*4;//為什么不是直接寫349
a_a = 1;
write_eeprom(); //保存數(shù)據(jù)
}
}
|