Can not read register 0 (R0) while CPU is running

问题一、cubemx生成工程,烧录程序后,不能再烧录。
问题二、5PIN端子SWD烧录器可以烧录,但是不能仿真。
程序仿真提示错误如下:
***JLink Error: CPU is not halted
***JLink Error: Can not read register 0 (R0) while CPU is running
***JLink Error: Can not read register 1 (R1) while CPU is running
***JLink Error: Can not read register 2 (R2) while CPU is running
***JLink Error: Can not read register 3 (R3) while CPU is running
***JLink Error: Can not read register 4 (R4) while CPU is running
***JLink Error: Can not read register 5 (R5) while CPU is running
***JLink Error: Can not read register 6 (R6) while CPU is running
***JLink Error: Can not read register 7 (R7) while CPU is running
***JLink Error: Can not read register 8 (R8) while CPU is running

解决方案一:
屏蔽代码:
// __HAL_AFIO_REMAP_SWJ_DISABLE(); //屏蔽

注意:cubemx重新生成工厂,需要再次屏蔽上行代码。

解决方案二:
在cubemx配置如下即可,仅使用SWD功能。
Can not read register 0 (R0) while CPU is running_第1张图片

你可能感兴趣的:(STM32)