fix(dwt): stop resetting CYCCNT, a counter six modules share
Three of the six DWT CYCCNT users wrote the counter to zero on init: console_log, net_latency_test and ch395f_reuse_bench. Every one of them only ever takes the difference (CYCCNT - t0) against a local snapshot, so the reset bought nothing and instead caused a bogus ~2^32 delta for anyone who sampled across it. That delta trips the task_prof glitch guard (TASK_PROF_GLITCH_CYC = 10 s worth of cycles), which discards the sample, so a whole worst-case measurement could vanish silently. All three call sites now leave the counter alone; the shared contract is "enable only, never reset", documented at each of the six users. The documented behaviour in the link latency test guide (section 4.3) is updated to match. Net source change is three deleted lines, no new executable code. Verification: - grep for a zero assignment to CYCCNT across the tree: no hits left. - Keil build: Code=257932 RO-data=32108 RW-data=2104 ZI-data=152688, 0 errors 0 warnings. - Host unit tests: console_log 153/153, task_prof 27/27, ioboard 100/100, sb_link 164/164. - Four console_log assertions pinned the absolute number of DWT register touches; dropping the reset write lowers it by one, so their expected counts move from 3 to 2 (and 4 to 3 for TC-CONLOG-093). The test text now says why the third write disappeared. - check_doc_links: 6 known issues, unchanged from baseline.
This commit is contained in:
@@ -184,9 +184,13 @@ static void prof_emit(uint32_t raw) {
|
||||
* 入口参数:无
|
||||
* 返回值:当前 CYCCNT 值(周期数)
|
||||
* 限定条件:任意上下文可调(幂等;纯寄存器读写)
|
||||
* 函数说明:只置使能位、**不清零** CYCCNT——本模块只用差值,清零无意义,
|
||||
* 且会与 console_log.c 的同名惰性使能互相干扰(该模块对 CYCCNT
|
||||
* 清零后,在途的差值会变成一次无符号回绕,由 glitch 守卫丢弃)。
|
||||
* 函数说明:只置使能位、**不清零** CYCCNT——本模块只用差值,清零无意义。
|
||||
* 本仓另有三个使用者共享这同一个计数器且同样取差值:App/log/console_log.c
|
||||
* (发送超时硬上界)、Drivers/BSP/IOBOARD/ioboard.c(微秒延时)、
|
||||
* Drivers/BSP/ScreenLink/sb_link.c(组帧耗时)。2026-11-16 之前
|
||||
* console_log.c 曾无条件清零,造成在途差值回绕、样本被 glitch 守卫吞掉;
|
||||
* 现四处口径统一为"只开不清"。**任何人再往这里加清零,等于让另外三处
|
||||
* 同时丢样本**,改之前先看本段。
|
||||
*/
|
||||
uint32_t task_prof_cyc(void) {
|
||||
if (s_dwt_ok == 0u) {
|
||||
|
||||
Reference in New Issue
Block a user