#define EepromStartAddress 0x0400
#define EepromEndAddress 0x0BFF
FCNFG =0X03; /*Force Double Bit Fault Detect*/
unsigned char g_uint8_EepGetByte(unsigned int b_u16_EepAddress)
{
unsigned char ReturnData,test;
if (b_u16_EepAddress<EepromStartAddress || b_u16_EepAddress>=EepromEndAddress ) {
return 0;
}
if(!FSTAT_CCIF) { // Is reading from EEPROM possible?
return 0; // If no then error
}
ReturnData=(*(unsigned char volatile*)b_u16_EepAddress);
asm("nop");
asm("nop");
asm("nop");
asm("nop");
test = FERSTAT;
if(FERSTAT&0x03)
{/*为什么每次读完检测ECC都有故障,查看读出数据有是正常地,请高手指教*/
FERSTAT |= 0x03;
return 0;
}
else
{
return ReturnData;
}
}
|