21ic问答首页 - GD32f407zet6 flash连续擦除扇区死机?
GD32f407zet6 flash连续擦除扇区死机?
wangkl112023-10-09
擦除函数: ram_fmc_unlock();
ram_ob_unlock();
/* clear pending flags */
fmc_flag_clear(FMC_FLAG_END | FMC_FLAG_OPERR | FMC_FLAG_WPERR | FMC_FLAG_PGMERR | FMC_FLAG_PGSERR);
/* wait the erase operation complete*/
for (sector_num = 0; sector_num < 5; sector_num++)
{
ram_fmc_state = ram_fmc_sector_erase(CTL_SN(sector_num));
if(ram_fmc_state!=FMC_READY)
{
while(1);
}
}
fmc_state_enum ram_fmc_sector_erase(uint32_t fmc_sector)
{
fmc_state_enum fmc_state = FMC_READY;
/*等待FMC准备好 */
fmc_state = ram_fmc_ready_wait();
if(FMC_READY == fmc_state) {
/* start sector erase */
FMC_CTL &= ~FMC_CTL_SN;
FMC_CTL |= (FMC_CTL_SER | fmc_sector);
FMC_CTL |= FMC_CTL_START;
/* wait for the FMC ready */
fmc_state = ram_fmc_ready_wait();
FMC_CTL &= (~FMC_CTL_SER);
FMC_CTL &= ~FMC_CTL_SN;
}
/* return the FMC state */
return fmc_state;
}
第一个扇区擦除正常,到第二个扇区就擦除成功后 返回也正常,ram_fmc_sector_erase函数运行完后死机
ram_ob_unlock();
/* clear pending flags */
fmc_flag_clear(FMC_FLAG_END | FMC_FLAG_OPERR | FMC_FLAG_WPERR | FMC_FLAG_PGMERR | FMC_FLAG_PGSERR);
/* wait the erase operation complete*/
for (sector_num = 0; sector_num < 5; sector_num++)
{
ram_fmc_state = ram_fmc_sector_erase(CTL_SN(sector_num));
if(ram_fmc_state!=FMC_READY)
{
while(1);
}
}
fmc_state_enum ram_fmc_sector_erase(uint32_t fmc_sector)
{
fmc_state_enum fmc_state = FMC_READY;
/*等待FMC准备好 */
fmc_state = ram_fmc_ready_wait();
if(FMC_READY == fmc_state) {
/* start sector erase */
FMC_CTL &= ~FMC_CTL_SN;
FMC_CTL |= (FMC_CTL_SER | fmc_sector);
FMC_CTL |= FMC_CTL_START;
/* wait for the FMC ready */
fmc_state = ram_fmc_ready_wait();
FMC_CTL &= (~FMC_CTL_SER);
FMC_CTL &= ~FMC_CTL_SN;
}
/* return the FMC state */
return fmc_state;
}
第一个扇区擦除正常,到第二个扇区就擦除成功后 返回也正常,ram_fmc_sector_erase函数运行完后死机
赞0
评论
2023-10-09
您需要登录后才可以回复 登录 | 注册