I am trying to get a periodic interrupt every 100 uS using TIMER4. My timers_init() code sets up the TIMER4 registers as follows:
NRF_TIMER4->PRESCALER = 4; NRF_TIMER4->CC[0] = 100; // Fbase = 16M/2^4 * 100 = 100 uS NVIC_EnableIRQ( TIMER4_IRQn); NRF_TIMER4->BITMODE = 0; //TIMER_BITMODE_16BIT; NRF_TIMER4->MODE = 0; NRF_TIMER4->INTENSET = TIMER_INTENSET_COMPARE0_Set << TIMER_INTENSET_COMPARE0_Pos; inten = NRF_TIMER4->INTENSET; NRF_TIMER4->TASKS_START = 1;
My interrupt service routine for now is a fairly simple increment of a variable but instead of hitting the breakpoint I set in the routine I end up in the Hard Fault handler:
void TIMER4_IRQHandler( void ) { static uint32_t loop = 0; if( NRF_TIMER4->EVENTS_COMPARE[0] ) { NRF_TIMER4->EVENTS_COMPARE[0] = 0; NRF_TIMER4->TASKS_CLEAR = 1; } loop++; return; }
Since the intent of this timer is to sample the LR register to generate a mapping of where the processor is spending its time I want to avoid any function calls after the actual timer interrupt.