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

Create timer in microseconds without nrf_delay_us and __nop() / __NOP()

Hey guys,

I have a timer like this:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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