I'm trying too use a timer as a counter on my nRF52840.
This is the function in question:
static void timer_init(void)
{
nrfx_timer_config_t timer_cfg = {
.mode = NRF_TIMER_MODE_COUNTER,
.bit_width = NRF_TIMER_BIT_WIDTH_32,
.frequency = NRF_TIMER_FREQ_1MHz,
.interrupt_priority = NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY,
.p_context = NULL
};
nrfx_err_t err = nrfx_timer_init(&timer, &timer_cfg, NULL);
if (err != NRFX_SUCCESS) {
printk("Timer init failed: %d\n", err);
return;
}
nrfx_timer_enable(&timer);
}
I have tried all frequencies and I get NRFX_ERROR_INVALID_PARAM with all of them expect for NRF_TIMER_FREQ_16MHz where I get:
[00:00:00.027,954] <err> os: ***** USAGE FAULT ***** [00:00:00.027,984] <err> os: Division by zero [00:00:00.028,015] <err> os: r0/a1: 0x0005223c r1/a2: 0x2000e12c r2/a3: 0x00f42400 [00:00:00.028,015] <err> os: r3/a4: 0x00000003 r12/ip: 0x00000000 r14/lr: 0x0003e1ef [00:00:00.028,045] <err> os: xpsr: 0x61000000 [00:00:00.028,045] <err> os: Faulting instruction address (r15/pc): 0x0003e106 [00:00:00.028,076] <err> os: >>> ZEPHYR FATAL ERROR 30: Unknown error on CPU 0 [00:00:00.028,137] <err> os: Current thread: 0x20006aa0 (main)
On line 86 of the nrfx_timer.c
I'm on nRF Connect SDK V3.0.2