Crystal Detection Code Not Triggering Task

Hi there,

At the moment, we have developed a custom PCB and are having wireless troubles. Our suspicion is that the crystal circuitry must be the issue as there is absolutely no advertising or trace of any sort of signal. Unfortunately, we do not have access to a spectrum analyzer and implemented the following function after Bluetooth advertising to check for the crystal. We went with this method because the registers to our understanding won't change due to the oscillator being switched on and off by the radio controller. However, even when we trigger for the oscillator (32Mhz) start task the register does not switch. Could we please have some assistance in debugging this issue ?

int wait_xtal_to_start(){
    uint16_t measured;// Start the HFCLK
    NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_HFCLKSTART = 1;

    // Wait for the HFCLK to start
    while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0)
    {
        xtal_time++;
        // Do nothing while waiting for the clock to start
    }

    // Check if the HFCLK is running on the external 32 MHz crystal
    if ((NRF_CLOCK->HFCLKSTAT & CLOCK_HFCLKSTAT_SRC_Msk) == CLOCK_HFCLKSTAT_SRC_XTAL_Msk)
    {
        // The HFCLK is running on the external 32 MHz crystal
        return xtal_time;
    }
    else
    {
        // The HFCLK is not running on the external 32 MHz crystal
        // This could indicate that the external crystal is not properly connected
        return -1;
    }
}

  • Hi,

     

    You should not use the registers directly when the stack is running.

    I would recommend that you run this specific function in a simpler firmware, ie. without bluetooth capabilities, to see if it actually starts up.

     

    If the 32M XO does not start up, I would recommend checking the physical orientation of the xtal as well as the solderings and load caps used.

     

    Kind regards,

    Håkon

Related