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

why timer of SDK 9.0 needn't code to trigger the clock.

I read timer example of SDK7.0/6.0, and found that often we write some code to tigger the clock. but the same example of SDK9.0 needn't. why ?

the code of SDK7.0: NRF_CLOCK->TASKS_HFCLKSTART = 1; to trigger the clock.

/**

  • @brief Function for timer initialization. */

static void timer_init()

{ // 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)
{
    // Do nothing.
}

NRF_TIMER0->MODE        = TIMER_MODE_MODE_Timer;       // Set the timer in Timer Mode.
NRF_TIMER0->PRESCALER   = 9;                           // Prescaler 9 produces 31250 Hz timer frequency => 1 tick = 32 us.
NRF_TIMER0->BITMODE     = TIMER_BITMODE_BITMODE_16Bit; // 16 bit mode.

}

Parents
  • The HFCLK is always running when the CPU is running or if a peripheral that requires it is active. (It can also be configured to run when it is not used, for constant latency, but it will increase the power consumption). The naming may be a bit confusing, but setting TASKS_HFCLKSTART actually starts the crystal oscillator, which is more accurate than the RC oscillator. If the application or peripheral (e.g. the radio) requires a accurate clock, the crystal oscillator must be used. If not, the RC is probably better as it starts up faster.

Reply
  • The HFCLK is always running when the CPU is running or if a peripheral that requires it is active. (It can also be configured to run when it is not used, for constant latency, but it will increase the power consumption). The naming may be a bit confusing, but setting TASKS_HFCLKSTART actually starts the crystal oscillator, which is more accurate than the RC oscillator. If the application or peripheral (e.g. the radio) requires a accurate clock, the crystal oscillator must be used. If not, the RC is probably better as it starts up faster.

Children
Related