Skip to content
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

fix(BLE): PalTimer Calibration #951

Merged
merged 1 commit into from
Mar 15, 2024

Conversation

BrentK-ADI
Copy link
Contributor

Updated the code for calibrating the PalTimer against the 32MHz clock. Original implementation only added adjustment on 100ms (PAL_TMR_CALIB_TIME) boundaries. In cases where the timer time was in between 100ms intervals, the timer could be severely early or late depending on how large usecDiff is.
``
The math could be accomplished by simply running (expUsec * palTimerCb.usecDiff) / PAL_TMR_CALIB_TIME; however there is not enough objective evidence for the max values of expUsec and usecDiff to show the multiplication won't overflow 32-bits. The math could be done in 64-bits, however the modulo method was used to keep this within a 32-bit scope.

@github-actions github-actions bot added the BLE Related to Bluetooth label Mar 14, 2024
@EricB-ADI
Copy link
Contributor

Yeah this is good, I am wondering why you cast the uint32_t to an int. It seems intentional, but not obvious as to why?

@BrentK-ADI
Copy link
Contributor Author

usecDiff can be negative, and the with the implicit conversion between the signed and unsigned types, I was getting incorrect values.

Looking at it though, int should probably be int32_t for consistency. Let me push up a change using the stdint type instead.

@github-actions github-actions bot added the MAX32690 Related to the MAX32690 (ME18) label Mar 15, 2024
@github-actions github-actions bot removed the MAX32690 Related to the MAX32690 (ME18) label Mar 15, 2024
@BrentK-ADI
Copy link
Contributor Author

Pushed up the wrong branch and made a big mess. 6f5ab8b should be good now.

@EricB-ADI EricB-ADI merged commit 65259f2 into analogdevicesinc:main Mar 15, 2024
7 checks passed
@BrentK-ADI BrentK-ADI deleted the ble_paltimer_fix branch March 15, 2024 18:37
EricB-ADI pushed a commit that referenced this pull request Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BLE Related to Bluetooth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants