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

Can someone explain to be how to set the timer interrupt for nrf51822?

Hi i'm a newbie in nordic chip. Can someone please explain to me that how to enable and configure the timer interrupt and what kind of setup need to be done?

Example in Arduino : [setting of set timer1 at 1s]

noInterrupts();  
TCCR1A = 0;                                     // mode of operation: normal
TCCR1B = 0;                                     // no clock source, mode of operation: normal
TCNT1  = 0;                                      // initialize counter value to 0
OCR1A  = 15624;                               // set compare match register to desired time count 
TCCR1B |= (1 << WGM12);                 // turn on clear timer on compare (CTC) mode
TCCR1B |= (1 << CS12);                     // set CS12 and CS10 bits to prescaler: 1024
TCCR1B |= (1 << CS10);
TIMSK1 |= (1 << OCIE1A);                  // enable timer compare interrupt
interrupts();                                     // enable all interrupts

ISR(TIMER1_COMPA_vect)                  // timer1 interrupt: 1s
{
}
Related