From c93860fae278fe5ca7fc84792f29684f309b90eb Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Fri, 14 Mar 2025 10:28:55 +0100 Subject: [PATCH] soc: nrf54l: fix LFXO INTCAP calculation formula The formula has been changed in latest version of the PS, adjust code accordingly. Signed-off-by: Gerard Marull-Paretas --- soc/nordic/nrf54l/soc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/soc/nordic/nrf54l/soc.c b/soc/nordic/nrf54l/soc.c index 475615271cf..737a0fbaa97 100644 --- a/soc/nordic/nrf54l/soc.c +++ b/soc/nordic/nrf54l/soc.c @@ -61,7 +61,7 @@ static inline void power_and_clock_configuration(void) int32_t slope_k = (int32_t)(slope_field_k ^ slope_sign_k) - (int32_t)slope_sign_k; /* As specified in the nRF54L15 PS: - * CAPVALUE = round( (CAPACITANCE - 4) * (FICR->XOSC32KTRIM.SLOPE + 0.765625 * 2^9)/(2^9) + * CAPVALUE = round( (2*CAPACITANCE - 12) * (FICR->XOSC32KTRIM.SLOPE + 0.765625 * 2^9)/(2^9) * + FICR->XOSC32KTRIM.OFFSET/(2^6) ); * where CAPACITANCE is the desired capacitor value in pF, holding any * value between 4 pF and 18 pF in 0.5 pF steps. @@ -82,7 +82,7 @@ static inline void power_and_clock_configuration(void) * offset_k should be divided by 2^6, but to add it to value shifted by 2^9 we have to * multiply it be 2^3. */ - uint32_t mid_val = (cap_val_encoded - 4UL) * (uint32_t)(slope_k + 392UL) + uint32_t mid_val = (2UL * cap_val_encoded - 12UL) * (uint32_t)(slope_k + 392UL) + (offset_k << 3UL); /* Get integer part of the INTCAP code */