I am using nRF Connect SDK 2.3.0 and nRF5340 DK. Below code uses the cdc_acm app as a base template.
I tried to use hardware timers with interrupts enabled via nrfx_timer.c but board would freeze/reset when it fired. I was able to verify that the cause seems to be that the IRQ was enabled as expected but no handler was properly setup, resulting in the spurious IRQ handler. Looking at the generated isr_tables.c I do not see an ISR installed for IRQ 16 (TIMER1_IRQn) or rather I see the placeholder instead.
Does this sound right? How do I convince the tool to do the right thing? I have CONFIG_NRFX_TIMER1=y set in proj.conf and am using the default DK app core device tree but with timer1 enabled in the overlay. Is there a setting I am missing? The Kconfig/DT should be setting this up, right?
I see another post or two with a similar issue but the answer involved the legacy SDK which doesn't seem to be in play here...
#define TEST_VALUE 60000 static const nrfx_timer_t my_test_timer = NRFX_TIMER_INSTANCE(1); static volatile uint32_t my_timer_ticks = 0; static void my_timer_handler(nrf_timer_event_t event_type, void *p_context) { my_timer_ticks += 1; } static void start_timer(void) { nrfx_err_t err_code; nrfx_timer_config_t tmr_config = NRFX_TIMER_DEFAULT_CONFIG; tmr_config.frequency = NRF_TIMER_FREQ_1MHz; tmr_config.mode = NRF_TIMER_MODE_TIMER; tmr_config.bit_width = NRF_TIMER_BIT_WIDTH_16; tmr_config.interrupt_priority = NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY; err_code = nrfx_timer_init(&my_test_timer, &tmr_config, my_timer_handler); nrfx_timer_extended_compare(&my_test_timer, NRF_TIMER_CC_CHANNEL1, TEST_VALUE, NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK, true); //nrfx_timer_extended_compare(&my_test_timer, NRF_TIMER_CC_CHANNEL1, TEST_VALUE, NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK, false); nrfx_timer_enable(&my_test_timer); }
&timer1 { status = "okay"; };
CONFIG_STDOUT_CONSOLE=y CONFIG_USB_DEVICE_STACK=y CONFIG_USB_DEVICE_PRODUCT="Zephyr CDC ACM sample" CONFIG_USB_DEVICE_PID=0x0001 CONFIG_LOG=y CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y CONFIG_SERIAL=y CONFIG_UART_INTERRUPT_DRIVEN=y CONFIG_UART_LINE_CTRL=y CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n CONFIG_NRFX_TIMER1=y