-
Notifications
You must be signed in to change notification settings - Fork 120
feat(PeriphDrivers): MAX32657 clock calibration #1468
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
base: main
Are you sure you want to change the base?
Conversation
| { | ||
| static const int CAL_MS = 10; | ||
| /* IPO_FREQ / ERTCOCC_FREQ, integer divide, rounded */ | ||
| static const int AUTOCAL2_DIV = (IPO_FREQ + (ERTCO_FREQ - 1)) / ERTCO_FREQ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comes out to 1526 if my math is correct, should it not be 3662? Even if 1526 was left shifted it would come out to 3052.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /* Leaving the calibration hardware running will result in a more accurate frequency on average. | ||
| * Trim trim settings will oscillate around the ideal frequency. | ||
| */ | ||
| MXC_FCR->autocal0 &= ~(MXC_F_FCR_AUTOCAL0_RUN); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any scenario where we might want a one-shot calibration and then shutdown the hardware, e.g. for power efficiency? If we want to leave the calibration hardware running, then should at least be documented in the header file for consumers, IMHO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clearing the run bit here makes this a one-shot calibration.

Description
Add pin configuration for RTC square wave output. Use a frequency counter to verify the RTC frequency. Adjust the trim values to get samples within crystal ppm specification.
Add IPO calibration function. Optionally leave the calibration procedure running to center the frequency. Each LSB of the trim value will be ~160 kHz.
Checklist Before Requesting Review