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

1 micro second interrupt using timer1? Softdevice is enabled.

Is it possible to have 1micro second interrupt using timer 1?

I am unable to achieve it.

If I try for 4micro second, I observe toggling of pin at 8 micro seconds?

Why so?

init:

TIMER1->TASKS_STOP = 1;   /* Stop timer */ 

TIMER1->MODE = TIMER_MODE_MODE_Timer;  /* taken from Nordic dev zone */

TIMER1->BITMODE = TIMER_BITMODE_BITMODE_16Bit;

TIMER1->PRESCALER = TIMER_PRESCALER;

TIMER1->CC[0] = 64;  /*for 4 micro second*/

TIMER1->TASKS_CLEAR = 1; /* Clear timer */	

TIMER1->INTENSET = TIMER_INTENSET_COMPARE0_Enabled << TIMER_INTENSET_COMPARE0_Pos;

TIMER1->SHORTS = (TIMER_SHORTS_COMPARE0_CLEAR_Enabled << TIMER_SHORTS_COMPARE0_CLEAR_Pos);		
				
NVIC_SetPriority(TIMER1_IRQn, 1);

NVIC_EnableIRQ(TIMER1_IRQn);				

TIMER1->TASKS_START = 1;

inside irq routine:

if(TIMER1->EVENTS_COMPARE[0])
{
    
    TIMER1->EVENTS_COMPARE[0] = 0;
			
    nrf_gpio_pin_toggle(17);
			
    TIMER1->SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Msk;
}
Parents Reply Children
No Data
Related