Hello,
I am trying to use nrfx timers from nrf v2.5.0 and I cam across a weird issue.
As I enable the CC interrupt a CPU fatal error happens:
00> [00:00:00.250,732] <err> os: >>> ZEPHYR FATAL ERROR 1: Unhandled interrupt on CPU 0
00> [00:00:00.250,762] <err> os: Current thread: 0x200089f0 (unknown)
00> [00:00:00.375,823] <err> fatal_error: Resetting system[0m
over and over again.
I tried to add this piece od code
IRQ_CONNECT(TIMER2_IRQn, 0, timer2_interrupt_handler, NULL, 0);
as I found in other posts but this causes the fw to hang on boot and never reach main:
00> *** Booting nRF Connect SDK v2.5.0 ***
I really do not know what is going on.
Thank you.
Here is the code:
static uint32_t old_cap = 0; static void timer2_interrupt_handler( nrf_timer_event_t event_type, void *p_context ) { uint32_t cap = nrfx_timer_capture_get(&m_timer2, NRF_TIMER_CC_CHANNEL0); if (cap != old_cap) { LOG_INF("cap: %d", cap); old_cap = cap; } } static void init_timer( void ) { nrfx_err_t err; nrfx_timer_uninit(&m_timer2); nrfx_timer_config_t tmr_config = NRFX_TIMER_DEFAULT_CONFIG(1000000); tmr_config.bit_width = (nrf_timer_bit_width_t)NRF_TIMER_BIT_WIDTH_16; err = nrfx_timer_init(&m_timer2, &tmr_config, timer2_interrupt_handler); if (err != NRFX_SUCCESS) { LOG_INF("nrfx_timer_init error: 0x%08X", err); } /* nrfx_timer_extended_compare(&m_timer2, NRF_TIMER_CC_CHANNEL0, 200, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true); */ nrfx_timer_compare(&m_timer2, NRF_TIMER_CC_CHANNEL0, 200, true); //nrfx_timer_compare_int_enable(&m_timer2, NRF_TIMER_CC_CHANNEL0); nrfx_timer_enable(&m_timer2); }