Hey guys,
I have a timer like this:
const nrf_drv_timer_t TIMER_SEND_DATA = NRF_DRV_TIMER_INSTANCE(1);
static void send_protocol(void) //function to send protocol to master
{
// do something...
}
/**
* @brief Handler for timer events.
*/
void timer_event_handler(nrf_timer_event_t event_type, void* p_context)
{
switch (event_type)
{
case NRF_TIMER_EVENT_COMPARE1:
send_protocol();
break;
default:
//Do nothing.
break;
}
}
static void timer_SendData_init()
{
uint32_t time_ms = 1000;
uint32_t time_ticks;
uint32_t err_code = NRF_SUCCESS;
//Configure TIMER_SEND_DATA for generating simple light effect - leds on board will invert his state one after the other.
nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
err_code = nrf_drv_timer_init(&TIMER_SEND_DATA, &timer_cfg, timer_event_handler);
APP_ERROR_CHECK(err_code);
time_ticks = nrf_drv_timer_ms_to_ticks(&TIMER_SEND_DATA, time_ms);
nrf_drv_timer_extended_compare(
&TIMER_SEND_DATA, NRF_TIMER_CC_CHANNEL1, time_ticks, NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK, true);
}
While this first timer (nrf_drv_timer) is running, I need a second timer whose interval I have to be able to change constantly.
E.g.
//Do this
time_us (10)
//Do that
time_us(60)
But the second timer must not influence the first. In this thread I created a timer with Håkon that uses __NOP()s. Unfortunately, these affect the first timer ...
To sum up: The second timer should be a single shot timer, whose interval I can change and which can not influence the first timer. And I know that RTC has a less resolution (~30us) but I need a resolution up to 1us. I think I can not use a timer like the first timer because of I can't changed the interval, right?
I hope, you can help me.
Thanks in advance,
Christoph