STM32L071 IAP升级时“Cannot access target.Shutting down debug session”问题

STLink_V2调试STM32L071 IAP功能时,执行到FLASH_If_Erase()出现以下

在这里插入图片描述

// 在以下代码中 增加1ms延时,解决问题。原因待解。
HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *PageError)
{
      /* If the erase operation is completed, disable the ERASE Bit */
      CLEAR_BIT(FLASH->PECR, FLASH_PECR_PROG);
      CLEAR_BIT(FLASH->PECR, FLASH_PECR_ERASE);

      if (status != HAL_OK) 
      {
        /* In case of error, stop erase procedure and return the faulty address */
        *PageError = address;
        break;
      }
	  HAL_Delay(1);		//不加debug时,自动退出  
    }
  }
}
发布了24 篇原创文章 · 获赞 0 · 访问量 479

猜你喜欢

转载自blog.csdn.net/lljss1980/article/details/104706651