NRFX and Zephyr Timer interrupt missing event_type

Hello! I'm working on an application with precise timing and I'm using timers and PPI.

In the callback pulse_end_cb() I seem to get garbage instead of the parameters, which makes it impossible to distinguish which event_type triggered the callback.
A snipped of representative code is below with the steps I'm using to register the IRQ and the callback. I think I have some confusion between the IRQ and the timer event handler, as it seems that the function is registered as callback but also used in the timer_init.

Can somebody clarify how to use this?

Thank you!

static void pulse_end_cb(nrf_timer_event_t event_type, void * p_context){
    // expected 320, but I get a random number instead
    if(event_type != NRF_TIMER_EVENT_COMPARE0){
        return;
    }

    LOG_INF("Calling pulse end callback");

}

...

IRQ_CONNECT(DT_IRQN(TIMER_NODE), DT_IRQ(TIMER_NODE, priority), nrfx_isr, pulse_end_cb, 0);

...

err = nrfx_timer_init(&timer, &timer_cfg, pulse_end_cb);
if(err != NRFX_SUCCESS){
    return err;
}

...

nrfx_timer_compare(&timer, NRF_TIMER_CC_CHANNEL0, nrfx_timer_us_to_ticks(&timer, duration_us), true);

PS: I took inspiration from this post: devzone.nordicsemi.com/.../nrfx-timers---unhandled-interrupt-on-cpu0

Related