NRF52840 Dongle HXFO Crystal for UART

Hello,

I am working a project that uses the NRF52840 dongle with BLE and UART to communicate to two separate devices while going through temperature cycles. I have not had any issues communicating with Bluetooth, however the UART seems to drift. I understand that the HXFO should be active when using UART to ensure stable communication, and I have attempted to activate it using the onboard external crystal of the 52840 dongle, and the Clock confirms that it is started and is active (Returns 0x10001), however there is still drift. Is there a different sequence of events or configuration that I should have in order to properly use UART with the HFXO on the dongle? I use Pins (P0.02/P1.15) with the UART Async API in the NCS SDK.

NRF_CLOCK->TASKS_HFCLKSTART = 1;
while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0)
		;
printk("HFCLK SRC %X", NRF_CLOCK->HFCLKSTAT);

Parents
  • Hello,

    The bluetooth stack requests and releases the HFXO before and after each protocol event to minimize idle current. So HFXO may be stopped again after you have started it. I recommend requesting the HFXO through the onoff API instead as shown below. Using this API ensures that the clock is not stopped when other SDK modules releases their clock request.

    #include <zephyr/drivers/clock_control/nrf_clock_control.h>
    
    void enable_hfxo(void)
    {
    	struct onoff_manager *clk_mgr;
    	static struct onoff_client cli = {};
    
    	clk_mgr = z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);
    	sys_notify_init_spinwait(&cli.notify);
    	(void)onoff_request(clk_mgr, &cli);
    }

    Best regards,

    Vidar

Reply
  • Hello,

    The bluetooth stack requests and releases the HFXO before and after each protocol event to minimize idle current. So HFXO may be stopped again after you have started it. I recommend requesting the HFXO through the onoff API instead as shown below. Using this API ensures that the clock is not stopped when other SDK modules releases their clock request.

    #include <zephyr/drivers/clock_control/nrf_clock_control.h>
    
    void enable_hfxo(void)
    {
    	struct onoff_manager *clk_mgr;
    	static struct onoff_client cli = {};
    
    	clk_mgr = z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);
    	sys_notify_init_spinwait(&cli.notify);
    	(void)onoff_request(clk_mgr, &cli);
    }

    Best regards,

    Vidar

Children
No Data
Related