AT32FCBT7存储问题,无法正确擦除FLASH,请大神指导
调用存储数据第一次存储(FLASH数据FF状态)数据正常,再次存储无法把FLASH正确擦除,ErasePage擦除函数返回状态2(写保护错误),函数如下。
void EEPROM_SaveInFlash (uint16 job, uint8 En)
{
uint8 ID,Number;
if (En == DEF_ENABLED ){ // ÄÚ²¿FLASH´¦Àí
FLASH_Unlock(); // FLASH½âËø
/* Clear All pending flags */
FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_PRCDN|FLASH_FLAG_PRGMFLR |FLASH_FLAG_WRPRTFLR);
FlashStatus = FLASH_ErasePage(EEPROM_START_ADDRESS);
WeldBuffer = 300;
WeldBuffer = 154;
WeldBuffer = Job_Data.MemorySetNub;
WeldBuffer = Job_Data.MIGSetVoltageCorrect;
WeldBuffer = Job_Data.MIGSetMotorSpeedCorrect;
WeldBuffer = Job_Data.MIGSetCurrentCorrect;
WeldBuffer = Job_Data.MIGDisCurrentCorrect;
WeldBuffer = Job_Data.K;
WeldBuffer = Job_Data.B;
WeldBuffer = Job_Data.TestCount;
WeldBuffer = Job_Data.TIG200_220_Fg;
WeldBuffer = Job_Data.MIGDisACVoltageCorrect;
for (ID = 0; ID < 61; ID++){
for (Number = 0; (Number < 150) && (FlashStatus == FLASH_PRC_DONE); Number++){
FlashStatus = FLASH_ProgramHalfWord((EEPROM_START_ADDRESS + (((ID * 150) + Number) * 2)), WeldBuffer);
}
}
FLASH_Lock(); // FLASHÉÏËø
} else { // ½ö½öÄÚ²¿RAM½»»»
for (Number = 0; Number < 150; Number++)
WeldBuffer = WeldBuffer;
}
}
先确认一下库函数版本,看一下擦除和编程函数内部是否有判断错误标识。单步调试跟进去看 两次操作间隔多久
页:
[1]