This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Timer change interval

Hello! How can I dynamically change timer interval by the button, without using PPI?

  • I understood.

    static void timer0_init(void)
    {
        NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
        NRF_CLOCK->TASKS_HFCLKSTART    = 1;
    
        while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) 
        {}
        pTimer->TASKS_CLEAR = 1;
        pTimer->PRESCALER = 4;
        pTimer->CC[0]     = 100;
        pTimer->MODE      = TIMER_MODE_MODE_Timer;
        pTimer->BITMODE   = TIMER_BITMODE_BITMODE_24Bit;
        pTimer->SHORTS    = (TIMER_SHORTS_COMPARE0_CLEAR_Enabled << TIMER_SHORTS_COMPARE0_CLEAR_Pos);
        pTimer->INTENSET = (TIMER_INTENSET_COMPARE0_Enabled << TIMER_INTENSET_COMPARE0_Pos);
    
        NVIC_EnableIRQ(TIMER0_IRQn);
        __enable_irq();
        pTimer->TASKS_START = 1;
    }
    

    And just need to change pTimer->CC[n]

Related