Fix systime_now_us() occasional fault#189
Merged
JcZou merged 1 commit intoFirmament-Autopilot:masterfrom Mar 9, 2026
Merged
Conversation
f22016a to
f0b3947
Compare
Pan-Chenliang
commented
Mar 8, 2026
| now_us = time_now_ms * 1000ULL + systick_us; | ||
|
|
||
| /* Fix the race condition where the SysTick hardware timer has wrapped around */ | ||
| if (now_us < monotonic_us) { |
Contributor
Author
There was a problem hiding this comment.
这里可能用while会更好?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
在 i2c timeout 故障中,捕捉两次调用systime_now_us的时间差,出现故障的时候时间差总是1000us。分析发现systime_now_us()有极小概率出现 毫秒+微妙 刚好多跳了一毫秒的情况。类似秒针跳到60,分针+1,但是秒针还没回0。此时的读取会多1000us,导致i2c超时函数直接判定超时。
经过在6c上测试,修改后50次启动中没有出现i2c启动失败的情况。