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

Changing sample rate/timer ticks when receiving data

Hi, I am currently working on a project, where I need to change my timer ticks whenever I receive a number from the UART app. The code for receiving data is complete, but then I need the the timer function/configuration to run whener I want to change it. Is there a way to how I can solve this?

Here is the timer function;

void timer_init(void) {

ret_code_t err_code;


err_code = nrf_drv_timer_init(&m_timer, NULL, timer_handler);
APP_ERROR_CHECK(err_code);

/* setup m_timer for compare event with SAADC_MS_BETWEEN_SAMPLE_RATE */
 uint32_t ticks = nrf_drv_timer_ms_to_ticks(&m_timer, data_pro_min*1000);

  // set up timer with  compare match on CHANNEL0, after ticks, and restart timer om match, and with IRQ disabled !
nrf_drv_timer_extended_compare(&m_timer, NRF_TIMER_CC_CHANNEL0, ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false); 
nrf_drv_timer_enable(&m_timer);

}

-Erblin

Related