Hello,
I am trying to use TIMER3 where it should count 1ms ticks for 15 seconds and then stop.
Tried the below code. However it never enters ISR.
Please let me know if I am configuring it incorrectly or something else.
As Channel 0 is being used by Timer 2 already, I have chosen channel 3.
Also tried setting priority to 3.
// Timer tick duration (1 ms = 16000 ticks at 16 MHz) #define TIMER_TICK_1MS 16000 // Total duration (15 seconds = 15000 ms) #define TIMER_DURATION_15S (15000 * TIMER_TICK_1MS) void hw_timer3_init(uint32_t tick_count) { // Stop Timer 3 before configuring nrf_timer_task_trigger(NRF_TIMER3, NRF_TIMER_TASK_STOP); // Configure TIMER3 in Timer mode nrf_timer_mode_set(NRF_TIMER3, NRF_TIMER_MODE_TIMER); // Set frequency to 16 MHz nrf_timer_frequency_set(NRF_TIMER3, NRF_TIMER_FREQ_16MHz); // Set the timer to 32-bit mode nrf_timer_bit_width_set(NRF_TIMER3, NRF_TIMER_BIT_WIDTH_32); // Set the compare value (tick_count) nrf_timer_cc_write(NRF_TIMER3, NRF_TIMER_CC_CHANNEL3, tick_count); // Enable interrupt for compare event on channel 3 nrf_timer_int_enable(NRF_TIMER3, NRF_TIMER_INT_COMPARE3_MASK); // Enable TIMER3 interrupt in NVIC NVIC_EnableIRQ(TIMER3_IRQn); // Configure the timer to auto-clear on compare match nrf_timer_shorts_enable(NRF_TIMER3, NRF_TIMER_SHORT_COMPARE3_CLEAR_MASK); } void TIMER3_IRQHandler(void) { // Check for COMPARE3 event if (nrf_timer_event_check(NRF_TIMER3, NRF_TIMER_EVENT_COMPARE3)) { nrf_timer_event_clear(NRF_TIMER3, NRF_TIMER_EVENT_COMPARE3); // Clear the event // Stop the timer nrf_timer_task_trigger(NRF_TIMER3, NRF_TIMER_TASK_STOP); // Set GPIO P1.03 high to indicate timer expiration nrf_gpio_pin_toggle(NRF_GPIO_PIN_MAP(1, PIN_P1_03)); } } Starting Timer 3 in main () nrf_timer_task_trigger(NRF_TIMER3, NRF_TIMER_TASK_CLEAR); nrf_timer_task_trigger(NRF_TIMER3, NRF_TIMER_TASK_START);