This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

HFCLKSTATE do not update to 0x10001

Hi, Everyone,

I am Using S130 and sdk 11.0.0.2-alpha with nRF51422 chip. I have two crystal in my custom pcb, one is 32 Khz crystal for LFCLK between XL1 and XL2 (pin 45,46 ) and other is 16Mhz HFCLK between XC1 and XC2(pin 37, 38)

Inside ble_stack_init()

I use either following only for 32Khz external osciilator initialization SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_250_PPM, NULL);

OR following only when using internal RC osc SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_TEMP_16000MS_CALIBRATION, NULL);

/****/

when I switch LFCLK to internal RC then HFCLK gets updated to 0x10001 -which is external 16Mhz crystal. All perfect , no problem

But when I use 32 Khz external crystal as LFCLK, HFCLK stays to 0x10000 - which says internal RC instead of external oscillator

According to the specs, Radio should not work without external crystal HF clock source, But I can see Advertised data in Master control panel, with accurate information even when i use external 32 khz crystal for LFCLK and HFLCK stays to 0x10000

Can anybody make me clear here ???

  • Hi

    The selection of the 16MHz clock source should be reflected in the HFCLKSTAT register, while the selection of 32kHz clock source should be reflected in the LFCLKSTAT register. When you enable the 32kHz crystal, that should not have any effect on the HFCLKSTAT register, but should set the first bit in the LFCLKSTAT register instead.

    I see this happen correctly on my nRF51422 IC. What might be happening is that you set a breakpoint immediately after setting the XTAL to see the register value. It may take some time for the CLOCK module to set crystal as the clock source. In my case if I stop at the breakpoint and then step once, the LFCLKSTAT will update to have XTAL selected.

    image description

    image description

  • This is exactly the same question you asked yesterday and I answered yesterday, don't repost questions ad nauseum just because you don't understand the first answer.

    And I told you the same thing, when you change the LF clock source there's no point looking at the HF clock source register, look at the LF clock source register.

    The HF clock source, as I also told you yesterday, is started and stopped as necessary by the softdevice when it needs to use the radio or do other things it needs the crystal source for, like for instance, calibrate the LF clock source.

    So HFCLOCK does not stay using the RC source, it will be turned on and off as required, and the state it's in just after you change the LF clock source is completely irrelevant.

  • I guess answer from stefan above explains the reason in better manner !!!

Related