-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Safe wrap timeouts in dshot #23312
Safe wrap timeouts in dshot #23312
Conversation
51e4e22
to
992e7d3
Compare
969e04f
to
f3c3fa1
Compare
f3c3fa1
to
6553047
Compare
Without this I saw all-0 watchdogs and desyncs on my Chimera. My suspicion is that the 64bit maths burns too much CPU in the ISRs. I have tested on 4.3 with this and all flies fine. I highly recommend we backport to 4.3. |
that makes no sense at all. The ISRs happen at most at the dshot rate, so 1kHz or so. The 64 bit maths adds a few cycles (about 40ns per 64 bit add or subtract)). A watchdog requires 2s without a watchdog pat. There must be something else going on. To be spending that much time in ISRs would require an interrupt storm |
On the F427 the CPU cost is more significant - 1.5%. On my bdshot F427 quad this would have pushed it over the edge into poorer flight performance. |
6553047
to
c3cfe84
Compare
I'm flying this on all my copters without issue. |
Have been flying with this for several months without issue. Since there are other places in the code where wraps can cause issues (e.g. ESC telemetry) and moving everything to 64bit is going to prove expensive, I would like to get this in - particularly the helper functions which I think enforces best practice as well as being much clearer to read in the code. |
18c9c70
to
3303393
Compare
3303393
to
9707744
Compare
9707744
to
7d25f63
Compare
Type safe version. Verified that you cannot use different types for the time values. 32 bit version is 280 bytes smaller than 64 byte version |
f9f5a19
to
375caf8
Compare
375caf8
to
3fd6e4e
Compare
On an F4 (MambaF405v2) 64-bit:
32-bit:
The 0.5% benefit is very consistent (so 2.8% benefit to the rcout thread), so a pretty decent bump for a change in type |
add tests for timeout functions
… require it correct timeout checking for dshot across timer wrap boundaries fix trigger_groups timeout checks use rcout_timer_t instead of uint32_t or uint64_t
3fd6e4e
to
0b70858
Compare
Refresh of #20430
This can safely use 32 bit timestamps in the rcout thread controlled via AP_RCOUT_USE_32BIT_TIME. The saves 100bytes of flash and about 0.7% CPU on an H7 which is fairly significant.