调用存储数据第一次存储(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[0][0] = 300;
WeldBuffer[0][1] = 154;
WeldBuffer[0][2] = Job_Data.MemorySetNub;
WeldBuffer[0][3] = Job_Data.MIGSetVoltageCorrect;
WeldBuffer[0][4] = Job_Data.MIGSetMotorSpeedCorrect;
WeldBuffer[0][5] = Job_Data.MIGSetCurrentCorrect;
WeldBuffer[0][6] = Job_Data.MIGDisCurrentCorrect;
WeldBuffer[0][7] = Job_Data.K;
WeldBuffer[0][8] = Job_Data.B;
WeldBuffer[0][9] = Job_Data.TestCount;
WeldBuffer[0][10] = Job_Data.TIG200_220_Fg;
WeldBuffer[0][11] = 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[ID][Number]);
}
}
FLASH_Lock(); // FLASHÉÏËø
} else { // ½ö½öÄÚ²¿RAM½»»»
for (Number = 0; Number < 150; Number++)
WeldBuffer[job][Number] = WeldBuffer[0][Number];
}
}
|