|
我才剛遇到這樣的情形
我是在已經設定讀保護的情況下,用ULINK清除Flash 以下是我用來解除寫保護的程式碼 在RAM中執行後 OK! int main (void) { FLASH_Status status = FLASH_COMPLETE;
Chip_Init();
UnlockFlash(); status = WaitForLastOperation(10); FLASH->OPTKEYR = FLASH_KEY1; FLASH->OPTKEYR = FLASH_KEY2;
FLASH->CR |= CR_OPTER_Set; FLASH->CR |= CR_STRT_Set;
status = WaitForLastOperation(10);
if(status == FLASH_COMPLETE) { /* if the erase operation is completed, disable the OPTER Bit */ FLASH->CR &= CR_OPTER_Reset;
/* Enable the Option Bytes Programming operation */ FLASH->CR |= CR_OPTPG_Set;
OB->RDP = RDP_Key; }
/* Wait for last operation to be completed */ status = WaitForLastOperation(10); if(status != FLASH_BUSY) { /* if the program operation is completed, disable the OPTPG Bit */ FLASH->CR &= CR_OPTPG_Reset; } while(1);
} |
|