使用的GPIO開發(fā)例程,SWD -> PD1, 程序無限重啟,幫忙看看哪里錯誤。
編譯的hex文件如果通過 WCH-LinkUnility 刷入芯片,并開啟SDI printf,可以在串口顯示printf內(nèi)容,顯示SystemClk:24000000,system_ch32v00x.c中定義的 #define SYSCLK_FREQ_48MHz_HSE? ?48000000, 系統(tǒng)時鐘應(yīng)該是48M才對啊。進入循環(huán)中?Delay_Ms(25); 會執(zhí)行幾次循環(huán)后重啟。驗證每次都只能運行幾次固定次數(shù)的循環(huán)。猜測系統(tǒng)時鐘設(shè)置不對或則是否有定時器或則看門狗啟動了?
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輸出,調(diào)試時發(fā)現(xiàn)系統(tǒng)在啟動后執(zhí)行第一個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!