Sorry for the silly question, but as it is mandatory to use sd_X function when it is possible to avoid collision, could you tell me if this code is the right way to use the 16MHz Timer 1?
Best regards
/** @brief Function for handling the Timer 1 interrupt.
*/
void TIMER1_IRQHandler(void)
{
NRF_TIMER1->CC[0] += TIMER_INTERVAL;
// Clear interrupt.
if ((NRF_TIMER1->EVENTS_COMPARE[0] == 1) &&
(NRF_TIMER1->INTENSET & TIMER_INTENSET_COMPARE0_Msk))
{
NRF_TIMER1->EVENTS_COMPARE[0] = 0;
}
if(toggle)
kernel_led_test_on();
else
kernel_led_test_off();
toggle = !toggle;
}
static void timer1_init(void)
{
uint32_t p_is_running;
uint32_t err_code;
// Configure timer
NRF_TIMER1->MODE = TIMER_MODE_MODE_Timer;
NRF_TIMER1->BITMODE = TIMER_BITMODE_BITMODE_16Bit;
NRF_TIMER1->PRESCALER = 9;
// Clear the timer
NRF_TIMER1->TASKS_CLEAR = 1;
NRF_TIMER1->CC[0] = TIMER_INTERVAL;
NRF_TIMER1->INTENSET = TIMER_INTENSET_COMPARE0_Enabled << TIMER_INTENSET_COMPARE0_Pos;
NRF_TIMER1->TASKS_START = 1;
err_code = sd_nvic_SetPriority(TIMER1_IRQn,APP_IRQ_PRIORITY_LOW);
APP_ERROR_CHECK(err_code);
err_code = sd_nvic_ClearPendingIRQ(TIMER1_IRQn);
APP_ERROR_CHECK(err_code);
err_code = sd_nvic_EnableIRQ(TIMER1_IRQn);
APP_ERROR_CHECK(err_code);
}