Skip to content
Commit f0f5f28f authored by Piotr Pryga's avatar Piotr Pryga Committed by Anas Nashif
Browse files

soc: nrf54l15: Fix LFXO INTCAP code calculations



There were two errors in calculations of LFXO INTCAP code:
- The value provided by DTS files is internal desired capacitance.
  The value from DTS has to be "encoded" before use in INTCAP
  calculations formula. The formula for encoding is:
  CAPACITANCE_CODE = (<desired_value> - 4pF) / 0.5
  Subtract of 4 is related with lowest value in the allowed range.
  Division by 0.5 is related with change to steps size.
  In former code the subtration of 4pF was missing.

- The mid_val calcuation was wrong due offset_k left shift by 4.
  It should be left shift by 3 to get total left shift of 9.
  That matches the left shift of former part of the equation.
  Final integer value was calculated by right shift 10, it should
  be right shift 9. Then rounding was done by use of mod by (1 << 10)
  It should be mod by (1 << 9) and compared with (1 << 8), that is
  half of 0-512 range.

Signed-off-by: default avatarPiotr Pryga <piotr.pryga@nordicsemi.no>
parent e0f8a8f1
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment