参考文档:
STM32调试,发现HAL_Init();之后无法调试,甚至无法让程序停下来 - asml - 博客园
症状
最近开始学习STM32Cube,发现新建工程后无法正常调试,过了HAL_Init();之后就无法继续调试了. 无法进行让程序暂停以及停止等操作.并在输出窗口不断刷出

ERROR: Can not read register xx while CPU is running
原因
cube新建工程的时候默认关掉了调试功能,需要打开
解决方法
在Pinout&Configuration -> System Core -> SYS 里面找到Debug,切换为JTAG(5Pins)重新生成代码即可
