Hi,
I am considering CAPVALUE on a module using nRF5340.
When I set the following in direct_test_mode of NCS v2.1.2, I got the following register value.
・CONFIG
CONFIG_SOC_HFXO_CAP_INTERNAL=y
CONFIG_SOC_HFXO_CAP_INT_VALUE_X2=24
・Register
XOSC32MCAPS(0x500045C4)
→0x10F
XOSC32MTRIM(0x00FF0C20)
→0xFFFFFDDF
I checked if XOSC32MCAPS value obtained here is correct. The formula is referenced below.
infocenter.nordicsemi.com/.../oscillators.html
First, since XOSC32MTRIM is 0xFFFFFDDF, OFFSET and SLOPE are:.
OFFSET:01110b
SLOPE:11111b
OFFSET is integer form, so it is 14 in decimal.
SLOPE is complement form, so it is -1 in decimal.
CAPACITANCE is 12, since CONFIG_SOC_HFXO_CAP_INT_VALUE_X2=24.
From the above, CAPVALUE is as follows.
CAPVALUE=((-1+56)*(12*2-14)+((14-8)<<4)+32)>>6
=646>>6
=10
=0xA
There is a difference between 0xF, which read the register after writing direct_test_mode to the module, and 0xA, which is the result of the calculation.
I think the reason is that SLOPE is not complement form but integer form.
・SLOPE as integer form
CAPVALUE=((31+56)*(12*2-14)+((14-8)<<4)+32)>>6
=966>>6
=15
=0xF
How do I make SLOPE complement form in the source code?
Best regards,
uba