使用的GPIO开发例程,SWD -> PD1, 程序无限重启,帮忙看看哪里错误。
编译的hex文件如果通过 WCH-LinkUnility 刷入芯片,并开启SDI printf,可以在串口显示printf内容,显示SystemClk:24000000,system_ch32v00x.c中定义的 #define SYSCLK_FREQ_48MHz_HSE 48000000, 系统时钟应该是48M才对啊。进入循环中 Delay_Ms(25); 会执行几次循环后重启。验证每次都只能运行几次固定次数的循环。猜测系统时钟设置不对或则是否有定时器或则看门狗启动了?
while(1) { printf("loop %d\n",1); Delay_Ms(25); GPIO_WriteBit(GPIOD, GPIO_Pin_0, (i == 0) ? (i = Bit_SET) : (i = Bit_RESET)); }
然后尝试在MRS中F8下载,串口没有任何printf输出,调试时发现系统在启动后执行第一个printf时提示 Hart unexpectedly reset!,程序无限重启,串口没有任何输出。
Open On-Chip Debugger 0.11.0+dev-02415-gfad123a16-dirty (2023-09-22-10:36)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'sdi'
Warn : Transport "sdi" was already selected
Ready for Remote Connections
Started by GNU MCU Eclipse
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : WCH-LinkE mode:RV version 2.11
Info : wlink_init ok
Info : clock speed 6000 kHz
Info : [wch_riscv.cpu.0] datacount=2 progbufsize=8
Info : [wch_riscv.cpu.0] Examined RISC-V core; found 1 harts
Info : [wch_riscv.cpu.0] XLEN=32, misa=0x40800014
[wch_riscv.cpu.0] Target successfully examined.
Info : starting gdb server for wch_riscv.cpu.0 on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
Info : device id = 0xac62abcd
Warn : Prefer GDB command "target extended-remote :3333" instead of "target remote :3333"
Info : [wch_riscv.cpu.0] Found 0 triggers
Info : [wch_riscv.cpu.0] Hart unexpectedly reset!
Info : [wch_riscv.cpu.0] Hart unexpectedly reset!
Info : [wch_riscv.cpu.0] Hart unexpectedly reset!
Info : [wch_riscv.cpu.0] Hart unexpectedly reset!
Info : [wch_riscv.cpu.0] Hart unexpectedly reset!
Info : [wch_riscv.cpu.0] Hart unexpectedly reset!
Info : [wch_riscv.cpu.0] Hart unexpectedly reset!