On the 54l15 chip, in the NCSv3.0 peripheral_uart example routine, when using timer20 to set a 1-second timer, the actual time is only 995ms.

peripheral_uart_1_timer20.zip

#include <nrfx_timer.h>

CONFIG_NRFX_TIMER20=y

#define TIMER_INST_IDX 20
const nrfx_timer_t timer_instance = NRFX_TIMER_INSTANCE(TIMER_INST_IDX);

void timer_event_handler(nrf_timer_event_t event_type, void *p_context)
{
    gpio_pin_set_raw(gpin[1].port, gpin[1].pin, 1);
    gpio_pin_set_raw(gpin[1].port, gpin[1].pin, 0);
    // nrfx_timer_clear(&timer_instance);
    
}

static void configure_timer(void)
{
    IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_TIMER_INST_GET(TIMER_INST_IDX)), IRQ_PRIO_LOWEST,
                NRFX_TIMER_INST_HANDLER_GET(TIMER_INST_IDX), 0, 0);
    nrfx_err_t err;

    nrfx_timer_config_t timer_config = {
		.frequency = NRFX_MHZ_TO_HZ(8),
		.mode      = NRF_TIMER_MODE_TIMER,
		.bit_width = NRF_TIMER_BIT_WIDTH_32,
        .interrupt_priority = NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY,
        .p_context = NULL,
	};
    err = nrfx_timer_init(&timer_instance, &timer_config, timer_event_handler);
    if (err != NRFX_SUCCESS) {
        LOG_ERR("nrfx_timer_init error: %08x", err);
        return;
    }

    nrfx_timer_clear(&timer_instance);

    nrfx_timer_extended_compare(&timer_instance, NRF_TIMER_CC_CHANNEL0, nrfx_timer_us_to_ticks(&timer_instance, 1000000),
        NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);

}

The attachment "peripheral_uart_1_timer20.zip" is the project engineering file. Actual tests show that timer20 is not as accurate as Ktimer.
Another strange thing is that even though I added &timer20 { status = "disable"; }; in the "overlay" file, timer20 can still run normally.
We urgently need your reply. Our PCB boards have arrived, and this timer is the most important function for our project.
Thank you very much.
Parents Reply Children
No Data
Related