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

problem with timer interrupts (NRF51822)

Hello,

i try to implement a simple timer interrupt on TIMER1 using one of the CC registers of the NRF51822. Here is my code:

void init_timers(void) {

// Start 32 MHz crystal oscillator
NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
NRF_CLOCK->TASKS_HFCLKSTART = 1;

// Wait for the external oscillator to start up
while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) {
	// Do nothing.
}

NRF_TIMER1->MODE = TIMER_MODE_MODE_Timer;
NRF_TIMER1->PRESCALER = TIMER_PRESCALER;

NVIC_EnableIRQ(TIMER1_IRQn);

NRF_TIMER1->CC[2] = 200;
NRF_TIMER1->INTENSET = TIMER_INTENSET_COMPARE2_Enabled
		<< TIMER_INTENSET_COMPARE2_Pos;

NRF_TIMER1->TASKS_START = 1;

    while(1);

}

void TIMER1_IRQHandler(void) { if (NRF_TIMER1->EVENTS_COMPARE[2] == 1) { NRF_TIMER1->EVENTS_COMPARE[2] = 0; //clear interrupt } }

When i try to debug my code and go into the while(1) loop the program counter (pc) get the value of 0xfffffffe. I suppose that the interrupt is generated but something goes wrong with the jump to the interrupt service routine void TIMER1_IRQHandler(void). Can explain to me how to implement a simple timer interrupt or provide a example. In the attachemnts is also my startUp file. I use GCC and eclipse.

best regards, Stefan

startup_nrf51.s

Parents Reply Children
No Data
Related