Skip to content

Conversation

@mstasiaknordic
Copy link
Contributor

Code responsible for internal capacitor values containted leftover workarounds in the calculations after PS update. Removed redundant conversions and cleaned up both code and comments to align both LFXO and HFXO calculation.

@github-actions github-actions bot added the platform: nRF Nordic nRFx label May 9, 2025
@mstasiaknordic mstasiaknordic changed the title soc: nordic: nrf54l: Clean up internal capacitance caltulations. soc: nordic: nrf54l: Clean up internal capacitance calculations. May 9, 2025
@mstasiaknordic mstasiaknordic force-pushed the nrf54l_lfxo_cap branch 2 times, most recently from db1b331 to ffa2c9b Compare May 9, 2025 10:49
Comment on lines 85 to 88
uint32_t lfxo_intcap = (lfxo_intcap_mid_val >> 9UL) / 1000UL;

/* Round based on fractional part */
if ((mid_val & BIT_MASK(9)) > (BIT_MASK(9) / 2)) {
/* Round based on fractional part. */
if (lfxo_intcap_mid_val % 1000 >= 500) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rounding is incorrect, since lfxo_intcap is lfxo_intcap_mid_val divided by 512000, not by 1000.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, corrected.


/* Get integer part of the INTCAP code */
uint32_t lfxo_intcap = mid_val >> 9UL;
/* Get integer part of the INTCAP code and concert to pico Farads. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: "concert"


/* Convert the calculated value to piko Farads */
uint32_t hfxo_intcap = mid_val_intcap / 1000;
/* Convert the calculated value to pikc Farads. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo "pikc"

/* Get integer part of the INTCAP code */
uint32_t lfxo_intcap = mid_val >> 9UL;
/* Get integer part of the INTCAP code and convert to pico Farads. */
uint32_t lfxo_intcap = (lfxo_intcap_mid_val >> 9UL) / 1000UL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make the rounding that follows a bit more obvious.

Suggested change
uint32_t lfxo_intcap = (lfxo_intcap_mid_val >> 9UL) / 1000UL;
uint32_t lfxo_intcap = lfxo_intcap_mid_val / 512000UL;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Code responsible for internal capacitor values containted
leftover workarounds in the calculations after PS update.
Removed redundant conversions and cleaned up both code
and comments to align both LFXO and HFXO calculation.

Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
@sonarqubecloud
Copy link

sonarqubecloud bot commented May 9, 2025

@kartben kartben merged commit 63f2fe9 into zephyrproject-rtos:main May 13, 2025
26 checks passed
@mstasiaknordic mstasiaknordic deleted the nrf54l_lfxo_cap branch May 20, 2025 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform: nRF Nordic nRFx

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants