Timer init returns Invalid Parameter nrF54L15 DK

We just started a project to replace an old PAN1720 and decided to use the nRF54L15 based module. So I am just getting started with the VS code and zephry enviroment using SDK v3.1.
I got the blinky example working, but now trying to use one of the timers to count edges on a port pin. Having issues with below code. The code compiles and flashes to the nrF54L15-DK board, but I get the below message from my jlink terminal when the init timer is called. Just starting out very basic to see if I can init a timer. I tried Timer 20 and timer 23 and both give the same result. I assume the function I am using is sending the wrong setup to the timer or the timer is not initialized. Any help would be appreciated. 

Putty output from Jlink com port
*** Booting nRF Connect SDK v3.1.0-6c6e5b32496e ***
*** Using Zephyr OS v4.1.99-1612683d4010 ***
STEP: test timer init
nrfx_timer_init failed: 195887108

below is my main.c
I have tried different frequencies and interrupt priorities, but get the same results. 
If I try setting it to 16MHz I get divide by zero errors. 

I also show my other file contents as well below. These files have alot of left over stuff from hours of trying to get this to work. 

#include <zephyr/kernel.h>
#include <nrfx_timer.h>

static const nrfx_timer_t my_timer = NRFX_TIMER_INSTANCE(20);

void main(void)
{
    printk("STEP: test timer init\n");

    nrfx_timer_config_t tcfg = {
        .frequency = NRF_TIMER_FREQ_2MHz,   // 1 MHz base clock
        .mode      = NRF_TIMER_MODE_TIMER,
        .bit_width = NRF_TIMER_BIT_WIDTH_32,
        .interrupt_priority = 6,
        .p_context = NULL,
    };

    nrfx_err_t err = nrfx_timer_init(&my_timer, &tcfg, NULL);
    if (err != NRFX_SUCCESS) {
        printk("nrfx_timer_init failed: %d\n", err);
        return;
    }

    nrfx_timer_enable(&my_timer);

    while (1) {
        k_msleep(500);
        printk("Timer running...\n");
    }
}

Overlay file

/ {
    aliases {
        rip-in = &rip_in0;
    };

    rip_in0: rip_in0 {
        status = "okay";
    };
};

/* Put phandle patches at top-level, not inside '/' */
&timer20 {
    status = "okay";
};

&gpiote30 {
    status = "okay";
};

/* Enable if you actually use DPPI later
&dppic00 {
    status = "okay";
};
*/

# Console over UART
CONFIG_PRINTK=y
CONFIG_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_UART_CONSOLE=y

#Enable Float formating
CONFIG_CBPRINTF_FP_SUPPORT=y

# Logging over UART (optional but nice)
CONFIG_LOG=y
CONFIG_LOG_PRINTK=y
CONFIG_LOG_BACKEND_UART=y
# CONFIG_LOG_BACKEND_RTT is disabled below

# Make sure RTT isn’t used for console/logs
CONFIG_USE_SEGGER_RTT=n
CONFIG_RTT_CONSOLE=n
CONFIG_LOG_BACKEND_RTT=n

# GPIO driver (this is the only one you need to set explicitly)
CONFIG_GPIO=y


CONFIG_NRFX_GPIOTE30=y     # GPIOTE instance 30 on nRF54L05 (cpuapp)
CONFIG_NRFX_TIMER20=y      # TIMER instance 20

# "no prompt" warning, just delete this line)
#CONFIG_NRFX_DPPI=y


Parents
  • Hello,

    The timer init function is returning "NRFX_ERROR_INVALID_PARAM" (195887108 / 0x0BAD0004), most likely due to the .frequency value. The NRF_TIMER_FREQ_* enum specifies the prescaler value, while the driver expects the frequency in hertz. Please replace the line  " .frequency = NRF_TIMER_FREQ_2MHz," with ".frequency = NRFX_MHZ_TO_HZ(2UL),"

    Best regards,

    Vidar

  • Thanks that was the solution. Is there any sample code on how to setup the Timers? I am trying to count rising edges on P1.09 using Timer20. I was able to init the Timer as a counter, but I am having trouble getting it to respond to the P1.09 square wave edge. My ultimate gol is to measure the frequency around 700KHz on P1.09. If there are no examples specifically for the nRF54L15 in the SDK or Zephyr, I will dig into the code and spec sheet deeper and figure it out or open another ticket with more specific information. As far as this ticket, I consider it solved.   
    Thank you for the help. 

Reply
  • Thanks that was the solution. Is there any sample code on how to setup the Timers? I am trying to count rising edges on P1.09 using Timer20. I was able to init the Timer as a counter, but I am having trouble getting it to respond to the P1.09 square wave edge. My ultimate gol is to measure the frequency around 700KHz on P1.09. If there are no examples specifically for the nRF54L15 in the SDK or Zephyr, I will dig into the code and spec sheet deeper and figure it out or open another ticket with more specific information. As far as this ticket, I consider it solved.   
    Thank you for the help. 

Children
Related