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

how to stop a timer ?

I am using 2 counters, one to produce the 4MHz, and the other for the 62.5KHz, to drive I2S module.

I need to find a way to stop the first counter (4MHz) after it produces a certain number of ticks (for example 512 ticks).

If I use the code (attached), the 4MHz timer does not produce pulses.

    nrf_drv_timer_config_t Timer_0_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
    Timer_0_cfg.frequency = NRF_TIMER_FREQ_8MHz;
    Timer_0_cfg.bit_width = NRF_TIMER_BIT_WIDTH_32;
    // Set up timer
    NRF_TIMER0->PRESCALER = 1;
    NRF_TIMER0->CC[0] = 1;
    NRF_TIMER0->CC[1] = 1;
    nrfx_timer_compare(&Timer_0, NRF_TIMER_CC_CHANNEL0, 1, false);
    nrfx_timer_extended_compare(&Timer_0, NRF_TIMER_CC_CHANNEL1, 512, NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK, false);

I am also not sure how to use the following:

NRF_TIMER0->CC[0], and would it be ignored if i use the function: nrfx_timer_extended_compare() ?

also:

NRF_TIMER_CC_CHANNEL1 and NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK in nrfx_timer_extended_compare(); how are the different from CHANNEL0/2/3 and COMPARE0/2/3_CLEAR_MASK

thanks

Related