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

Change tick value of timer compare event

Hello,

I'm using TIMER1 to generate a timer compare event. I connect the event with the sample task of the saadc like in the saadc example from the SDK. Everything works fine.

But now I want to change the tick value of the timer compare event after the saadc-sampling started. I thought I would have to disable the timer, set it with the new tick value to extended compare, enable it again and then assign the new event adress to the ppi channel like in the following code:

        nrf_drv_timer_disable(&gTimer);

        uint32_t ticks = nrf_drv_timer_us_to_ticks(&gTimer, newTickValue);

 	    nrf_drv_timer_extended_compare(&gTimer,
                                   NRF_TIMER_CC_CHANNEL1,
                                   ticks,
                                   NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK,
                                   false);

   	    nrf_drv_timer_enable(&gTimer);

    	uint32_t timer_compare_event_addr = rf_drv_timer_compare_event_address_get(&gTimer,
                                                                                NRF_TIMER_CC_CHANNEL1);
        uint32_t saadc_sample_task_addr   = nrf_drv_saadc_sample_task_get();

        errCode = nrf_drv_ppi_channel_assign(gPpiChannel,
                                          timer_compare_event_addr,
                                          saadc_sample_task_addr);

But it doesn't work, no saadc callback is called anymore. Also tried to free the ppi channel before giving the adress to it and I also tried to uninitialize the timer and ppi completely and init it again but I miss something because nothing seems to work.

I'm thankful for any advice.

Regards Lea

Related