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:
@@ -154,7 +154,8 @@ ENABLE_PHASE14_TESTS [网] 生产路径时延(生产路径帧周期~uiTask
|
||||
### 4.3 时基(DWT CYCCNT)
|
||||
|
||||
- 工程内首个 DWT 用户(`sys_clock` 是纯 HAL tick,无 µs 能力);`lat_time_init()` 幂等使能
|
||||
`CoreDebug->DEMCR | TRCENA` + `DWT->CYCCNT=0` + `DWT->CTRL | CYCCNTENA`;
|
||||
`CoreDebug->DEMCR | TRCENA` + `DWT->CTRL | CYCCNTENA`(**刻意不清零 CYCCNT**:本模块只用
|
||||
前后两次读数差值,而 CYCCNT 为全内核共享,清零会打乱其余四个使用者在途的计时基准);
|
||||
- 分辨率 1/168MHz ≈ 5.95ns;换算用 `SystemCoreClock`(不写死频率);
|
||||
- **32 位回绕 = 25.17ms**:M1 各段(<5ms)与 M2 调用方侧测量(单次 <25ms)用单次读数差;
|
||||
跨 25ms 的段(芯片→线上+PC/生产路径帧周期整帧与重传尖峰)由 PC 端 peer 计时,或 MCU 侧**累积采样**
|
||||
|
||||
Reference in New Issue
Block a user