写了段Eeprom的程序
能写进去擦除不了
程序如下
unsigned char EepromErase(unsigned char size) { unsigned int *pAddress; while(!(ECLKDIV & 0x80)); while(!(ESTAT & 0x80)); while(!(EPROT & 0x80)); pAddress=(unsigned int*)(0x2000); if(ECLKDIV_EDIVLD == 1) { if((ESTAT_ACCERR == 0) && (ESTAT_PVIOL == 0)) { while(size) { if(ESTAT_CBEIF == 1) { ECMD =0x40; ESTAT_CBEIF = 1; pAddress += 2; if((ESTAT_ACCERR == 1) || (ESTAT_PVIOL == 1)) { return 1; break; } while (ESTAT_CCIF == 0); size--; } } return 0; } else return 1; } else return 1; }
没有报错
我分配的Eeprom空间从2000到27ff
请各位大侠指教 |