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

TIMER1 hangs within a s132 timeslot

Hi,

I have a ble scanner working well and i am trying to trigger start a compare timer within a timeslot.

starting the timer in the timeslot with the below code makes everything hangs.

any clue?

Thanks in advance

void IrHandler::_EnableTimerOffset() {
    NRF_TIMER1->TASKS_STOP = 1;

    // Create an Event-Task shortcut to clear Timer on COMPARE[0] event.
    NRF_TIMER1->SHORTS     = (TIMER_SHORTS_COMPARE0_CLEAR_Enabled << TIMER_SHORTS_COMPARE0_CLEAR_Pos);
    NRF_TIMER1->MODE       = TIMER_MODE_MODE_Timer;
    //NRF_TIMER1->BITMODE    = (TIMER_BITMODE_BITMODE_24Bit << TIMER_BITMODE_BITMODE_Pos);
    NRF_TIMER1->PRESCALER  = 4;  // 1us resolution

    // Sample update needs to happen as soon as possible. The earliest possible moment is MAX_SAMPLE_LEVELS
    // ticks before changing the output duty cycle.
    NRF_TIMER1->INTENSET   = (TIMER_INTENSET_COMPARE0_Set << TIMER_INTENSET_COMPARE0_Pos);
    NRF_TIMER1->CC[0]       = 100;


    sd_nvic_ClearPendingIRQ(TIMER1_IRQn);
    sd_nvic_SetPriority(TIMER1_IRQn, APP_IRQ_PRIORITY_LOW);
    sd_nvic_EnableIRQ(TIMER1_IRQn);

    NRF_TIMER1->TASKS_START = 1;
}

void TIMER1_IRQHandler(void)
{
	NRF_TIMER1->TASKS_STOP = 1;
}

image description

It looks like the board crashes when calling the handler.

I have tried with nrf_drv_timer but the timer fires immediatly or so.

Related