How to configure Low-frequency external source in Zephyr?

I would like to use an external clock for the nrf5340. 

The documentation indicates that it is posible override the LFCLK control system to set another source by writing the register LFCLKSRC.

Documentation: https://infocenter.nordicsemi.com/topic/ps_nrf5340/chapters/clock/doc/clock.html?cp=3_0_0_3_10_1_0#concept_acb_q5y_2q

How do I write this register in Zephyr before the Zephyr kernel automatically initializes it?

  • Hi,

    The lfclk source is controlled through config options that you enable in the prj.conf file for your application.

    If you have an external 32kHz crystal in you design you can use e.g.:
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_XTAL=y
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_50PPM=y

    If you don't have an external 32kHz crystal you can use, eg.:
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION=y
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y

    Be aware that the nRF5340 have two cores, network and application. You should set the same 32kHz source for both cores. This can be done by for instance update both projects with the same configuration (e.g. update prj.conf for both network and application project).

    But alternatively when you build the application project, then it automatically build the child image for the network core, so there is an alternative way of setting up the two cores to use the same 32kHz as described here:

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_multi_image.html?highlight=child%20image#image-specific-variables 

    In short: You can make some directories under your application '\child_image\NETWORK_CORE_PROJECT_NAME\prj.conf' with the config lines above.

    Best regards,
    Kenneth

Related