test(vd960DBN): UART2 隔离实验 — 软件禁用 Loop 口定位复位源

现场: RST_REASON 全 0 瞬态复位, 总在 Loop 帧后 ~10ms, 指向 Loop 侧干扰
实验: uart_init 后立即禁用 USART2 + PA3 脱离 UART 功能(上拉输入)
     = 等效软件断开 Loop; 同时快照无帧入队, 同步验证 SPI 活动非诱因
判定: 不复位+无乱码 → Loop 数据路径干扰实锤
      还复位 → 物理引脚级干扰 或 CH32 自身电源问题
通过后删除此块
This commit is contained in:
wangfq
2026-08-12 19:15:37 +08:00
parent eadc67584f
commit 06fb009773
@@ -331,6 +331,23 @@ int main(void)
HAL_Init();
uart_init();
/* ===== 实验: 禁用 UART2 (Loop 口) 隔离测试 (2026-08-12) =====
目的: 验证 Loop MCU 数据/干扰是否导致复位循环 (RST_REASON 全 0 瞬态复位)
做法: USART2 关断 + PA3 脱离 UART 功能(上拉输入) — 等效软件断开 Loop
通过后删除此块; 另: 禁用后快照无帧入队, 同步验证快照 SPI 活动非诱因 */
{
GPIO_InitTypeDef gpio;
USART_ITConfig(USART2, USART_IT_RXNE, DISABLE);
USART_Cmd(USART2, DISABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
gpio.GPIO_Pin = GPIO_Pin_3;
gpio.GPIO_Mode = GPIO_Mode_IPU; /* PA3 脱离 UART2, 上拉输入 */
gpio.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &gpio);
PRINT("ISOLATE: UART2 disabled (Loop isolation test)\n");
}
TIM3_Init();
TIM2_Init();