使用STM32CubeMx生成STM32F205RE的驱动代码,调用HAL_FLASHEx_Erase函数无法擦除Sector,测试代码如下:
FLASH_EraseInitTypeDef EraseInitTypeDefStruct;
uint32_t SectorError;
EraseInitTypeDefStruct.Banks = 0;
EraseInitTypeDefStruct.NbSectors = 1;
EraseInitTypeDefStruct.Sector = FLASH_SECTOR_2;
EraseInitTypeDefStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
EraseInitTypeDefStruct.VoltageRange = FLASH_VOLTAGE_RANGE_3;
if (HAL_FLASHEx_Erase(&EraseInitTypeDefStruct, &SectorError) == HAL_OK)
{
DebugPrintfLn(MOD_PROJ_INFO, "Flash Erase OK, SectorError: %08X", SectorError);
}
else
{
DebugPrintfLn(MOD_PROJ_INFO, "Flash Erase Error");
}
测试打印的结果为:
[PROJ_INFO]Flash Erase OK, SectorError: FFFFFFFF
香主及各位大虾可知道是怎么回事啊! |