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

What is the High frequency clock model for nRF51?

Parents
  • There are two high frequncy clock sources for the nRF51 chip, an external 16MHz crystal and the internal 16MHz RC. Both of these clock sources need to be present as the Radio requires an external 16MHz 40ppm crystal in order to opterate. What clock sources different peripherals require is shown in table 33 in section 8.3 in the nRF51822 PS v3.1. The table shows e.g. that the radio peripheral requires the 16MHz crystal, while the UART only requires 16MHz internal RC.

    When a peripheral is enabled that requires the 16MHz RC, the RC is automatically enabled. However, when a peripheral requires the 16MHz crystal, the crystal needs to be started manually. It can be done with the following code:

    /* Start 16 MHz crystal oscillator */
    NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_HFCLKSTART = 1;
    
    /* Wait for the external oscillator to start up */
    while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) {}
    

    then stop the crystal again to save current with

    NRF_CLOCK->TASKS_HFCLKSTOP = 1;
    

    While starting the crystal, the internal RC continues to provide the HFCLK to peripherals. When the crystal is fully enabled and ready to provide the HFCLK, the RC is shut down. When the crystal is disabled again, the RC is started again, but only if any peripheral is enabled that requires HFCLK.

    After manually starting the HFCLK crystal it will be enabled even though there are no peripherals requesting the HFCLK. When no peripherals request the crystal it will reside in standby mode where the current consumption is around 25uA, compared to 470uA when it is in use, see nRF51822 PS v3.1, table 22. When a peripheral needs the HFCLK, it will be ready in standby mode and there is no startup time.

    When softdevice is enabled however, the softdevice will be in control of the high frequency crystal and automatically enables the crystal before a radio event and disables the crystal after a radio event, in order to save current. If the application needs to enable the 16MHz crystal while the softdevice is enabled, it must do so by calling the following softdevice functions:

    A code reference that shows how to use those softdevice functions is e.g. found in this example on Nordic's Github.

Reply
  • There are two high frequncy clock sources for the nRF51 chip, an external 16MHz crystal and the internal 16MHz RC. Both of these clock sources need to be present as the Radio requires an external 16MHz 40ppm crystal in order to opterate. What clock sources different peripherals require is shown in table 33 in section 8.3 in the nRF51822 PS v3.1. The table shows e.g. that the radio peripheral requires the 16MHz crystal, while the UART only requires 16MHz internal RC.

    When a peripheral is enabled that requires the 16MHz RC, the RC is automatically enabled. However, when a peripheral requires the 16MHz crystal, the crystal needs to be started manually. It can be done with the following code:

    /* Start 16 MHz crystal oscillator */
    NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_HFCLKSTART = 1;
    
    /* Wait for the external oscillator to start up */
    while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) {}
    

    then stop the crystal again to save current with

    NRF_CLOCK->TASKS_HFCLKSTOP = 1;
    

    While starting the crystal, the internal RC continues to provide the HFCLK to peripherals. When the crystal is fully enabled and ready to provide the HFCLK, the RC is shut down. When the crystal is disabled again, the RC is started again, but only if any peripheral is enabled that requires HFCLK.

    After manually starting the HFCLK crystal it will be enabled even though there are no peripherals requesting the HFCLK. When no peripherals request the crystal it will reside in standby mode where the current consumption is around 25uA, compared to 470uA when it is in use, see nRF51822 PS v3.1, table 22. When a peripheral needs the HFCLK, it will be ready in standby mode and there is no startup time.

    When softdevice is enabled however, the softdevice will be in control of the high frequency crystal and automatically enables the crystal before a radio event and disables the crystal after a radio event, in order to save current. If the application needs to enable the 16MHz crystal while the softdevice is enabled, it must do so by calling the following softdevice functions:

    A code reference that shows how to use those softdevice functions is e.g. found in this example on Nordic's Github.

Children
Related