FLASH_EraseInitTypeDef eraseInit;
eraseInit.TypeErase = FLASH_TYPEERASE_PAGES;
eraseInit.Banks = FLASH_BANK_2;
eraseInit.Page = 254;
eraseInit.NbPages = 2;
uint32_t PageError;
HAL_FLASH_Unlock();
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |FLASH_FLAG_PGAERR |FLASH_FLAG_PGSERR);
if(HAL_OK != HAL_FLASHEx_Erase(&eraseInit,&PageError))
{
printf("PageError:%d\n",PageError);
HAL_FLASH_Lock();
}
HAL_FLASH_Lock();
printf("erase ok\n");
大家有遇到过吗,麻烦看看代码有什么问题没? |