问题描述:在使用HC32F460擦除内部flash的时候,会卡死,进入断点debug发现,在EFM_SectorErase(uint32_t u32Addr)函数,执行到RW_MEM32(u32Addr) = 0UL;之前正常,执行此句之后,EFM_FSR的值为0x00000130,也就是COLERR标志报错,接下来这几步操作
/* Wait for ready flag. */
if (LL_ERR_TIMEOUT == EFM_WaitFlag(EFM_FLAG_RDY << u8Shift, EFM_ERASE_TIMEOUT)) {
i32Ret = LL_ERR_NOT_RDY;
}
/* Clear the operation end flag */
EFM_ClearStatus(EFM_FLAG_OPTEND << u8Shift);
/* Set read only mode. */
MODIFY_REG32(CM_EFM->FWMC, EFM_FWMC_PEMOD, EFM_MD_READONLY);
/* Recover CACHE */
MODIFY_REG32(CM_EFM->FRMC, EFM_CACHE_ALL, u32Tmp);
会卡死,偶尔是进入HardFault_Handler,此时R13(SP)的值为0x1FFF9130,R14(LR)的值为0xFFFFFFE9,R15(PC)的值为0xFBB02132;EFM_FWMC的值还为0x00000141,EFM_FSR的值还为0x00000130,说明应该是卡在
if (LL_ERR_TIMEOUT == EFM_WaitFlag(EFM_FLAG_RDY << u8Shift, EFM_ERASE_TIMEOUT)) {
i32Ret = LL_ERR_NOT_RDY;
}
求助点:
1:为何擦除失败;
2:为什么等待ready标志位会卡死(一句一句断点偶尔是正常的) |