这是我擦除的函数
void flash_page_erase(uint32_t address)
{
u8 tempPageNum;
HAL_StatusTypeDef test = HAL_FLASH_Unlock();
test = FLASH_WaitForLastOperation(1000); //1s timeout
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR);
tempPageNum=(address-0x08000000)/2048;
FLASH_PageErase(FLASH_BANK_1,tempPageNum-1);
test = FLASH_WaitForLastOperation(1000);
CLEAR_BIT(FLASH->CR, FLASH_CR_PER);
HAL_FLASH_Lock();
}
![img]([img]https://img-mid.csdnimg.cn/release/static/image/mid/ask/564413971926137.png[/img] '1629179246(1).png')
|