有没有大神遇到过,在连续擦除扇区,程序死了,找不到原因代码如下?
for (sector_num = 0; sector_num < 5; sector_num++)
{
ram_fmc_state = ram_fmc_sector_erase(CTL_SN(sector_num));
fmc_flag_clear(FMC_FLAG_END | FMC_FLAG_OPERR | FMC_FLAG_WPERR | FMC_FLAG_PGMERR | FMC_FLAG_PGSERR);
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;
}
仿真查看 擦除函数运行完就死机了,rerurn 返回值正常 |