From e0e79db40ec4ddfee5cf67f9aed80adb77a29ad2 Mon Sep 17 00:00:00 2001 From: wangfq Date: Fri, 26 Jun 2026 16:17:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20CAPVD=5Ffast=20=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E6=9D=A1=E4=BB=B6=E9=94=99=E8=AF=AF=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E5=A7=8B=E7=BB=88=E4=B8=BA=200?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因: TMR3 ISR 首次捕获时直接设置 loop1_CAPVD (不为 0), 导致 vd1_task 的 if(CAPVD==0) 分支永远不执行, CAPVD_fast 保持 INIT_VD 的 0 值。 修复: CAPVD_fast 判断改为 ==0 时首次锁定为当前 CAPVD 值, 后续正常执行快速 IIR 更新。 --- utilities/at32f421_freertos_demo/src/TaskLoop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utilities/at32f421_freertos_demo/src/TaskLoop.c b/utilities/at32f421_freertos_demo/src/TaskLoop.c index 62cb569..7a977e5 100644 --- a/utilities/at32f421_freertos_demo/src/TaskLoop.c +++ b/utilities/at32f421_freertos_demo/src/TaskLoop.c @@ -665,7 +665,9 @@ void vd1_task(void) } /* 1b. 快速 IIR — α=0.5: (old + new) / 2 */ - if (loop1_CAPVD_fast != 0) { + if (loop1_CAPVD_fast == 0) { + loop1_CAPVD_fast = loop1_CAPVD; // 首次直接锁定 + } else { loop1_CAPVD_fast = (loop1_CAPVD_fast + loop1_CAPVD) / 2; }