en_result_t EFM_SectorErase(uint32_t u32Addr)
{
uint8_t u8tmp;
uint16_t u16Timeout = 0u;
en_result_t enRet = Ok;
DDL_ASSERT(IS_VALID_FLASH_ADDR(u32Addr));
EFM_ClearFlag(EFM_FLAG_WRPERR | EFM_FLAG_PEPRTERR | EFM_FLAG_PGSZERR |
EFM_FLAG_PGMISMTCH | EFM_FLAG_EOP | EFM_FLAG_RWERR);
u8tmp = (uint8_t)M4_EFM->FRMC_f.CACHE;
M4_EFM->FRMC_f.CACHE = Disable;
EFM_ErasePgmCmd(Enable);
EFM_SetErasePgmMode(SectorErase);
*(uint32_t*)u32Addr = 0x12345678u;
while(1ul != M4_EFM->FSR_f.RDY)
{
u16Timeout++;
if(u16Timeout > 0x1000u)
{
enRet = ErrorTimeout;
}
}
EFM_ClearFlag(EFM_FLAG_EOP);
EFM_SetErasePgmMode(ReadOnly1);
EFM_ErasePgmCmd(Disable);
M4_EFM->FRMC_f.CACHE = u8tmp;
return enRet;
}
单步运行到这句话 就会卡死
*(uint32_t*)u32Addr = 0x12345678u;
写256字节数据 会多出来四个字节 |