fix(bmp388): correct timestamp_sample to integration midpoint#26920
Merged
fix(bmp388): correct timestamp_sample to integration midpoint#26920
Conversation
The BMP388 pressure measurement is integrated over a configurable window (e.g. 37ms at 16x oversampling). The previous code used the read time as timestamp_sample, which is the end of the integration window. Correct to the midpoint by subtracting half the measurement time, with a guard against unsigned underflow.
Contributor
Author
|
I will follow up on this PR with fixes for every baro and mag driver. Related to #26921 |
julianoes
approved these changes
Mar 31, 2026
hamishwillee
pushed a commit
that referenced
this pull request
Apr 1, 2026
The BMP388 pressure measurement is integrated over a configurable window (e.g. 37ms at 16x oversampling). The previous code used the read time as timestamp_sample, which is the end of the integration window. Correct to the midpoint by subtracting half the measurement time, with a guard against unsigned underflow.
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.
Summary
The BMP388/BMP390 pressure measurement is integrated over a configurable window (e.g. 37ms at 16x oversampling). The current code uses the SPI read time as
timestamp_sample, which corresponds to the end of the integration window. This introduces a systematic timing bias equal to half the measurement time (~18.5ms at 16x oversampling).This PR corrects
timestamp_sampleto the integration midpoint by subtractingmeasurement_time / 2, with a guard against unsigned underflow.This improves time alignment for all downstream consumers (EKF baro fusion, logging, etc.).
Changes
src/drivers/barometer/bmp388/bmp388.cpp: Replacehrt_absolute_time()with midpoint-corrected timestampTest plan