Hello, the title is pretty descriptive.
I've tried to read through previous questions and got a rough idea but decided that it would cost too much time for me to explore everything on my own so here I am asking this question.
I copied pretty much everything off that peripheral/timer example in the sdk, but now the symptom is that it fires off way too quickly.
So here are my questions, please do not reply if there is nothing needed to be done or I have got it correct, just answer those that I got wrong or something MUST BE done, just to save your time:
-
nrf_drv_timer_init function, should I modify anything in the first parameter: p_instance? Prescaler?
-
Same function as above, 2nd parameter, what should I change to p_config in order to make timer2 fire off every 5 seconds? For example, bit_width?
-
What on earth does "nrf_drv_timer_ms_to_ticks" do? I filled the 2nd parameter with 5000, but it clearly wasn't 5 seconds per compare event?
-
Last, but not least, "nrf_drv_timer_extended_compare", is my parameters correct?
nrf_drv_timer_extended_compare( &TIMER_READ_SENSORS, NRF_TIMER_CC_CHANNEL0, time_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);
Here is a snip of my relevant code:
APP_ERROR_CHECK(nrf_drv_timer_init(&TIMER_READ_SENSORS, NULL, timer_led_event_handler));
uint32_t time_ticks = nrf_drv_timer_ms_to_ticks(&TIMER_READ_SENSORS, 500000);//5Ãë¶ÁÒ»´Î
nrf_drv_timer_extended_compare(
&TIMER_READ_SENSORS, NRF_TIMER_CC_CHANNEL0, time_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);
nrf_drv_timer_enable(&TIMER_READ_SENSORS);