Other Timer/Counter setup fails if Timer0 is disabled using zephyr drivers for nRF52833

Hi folks,

we're running zephyr v3.6.0 on ublox-anna-b412 module which embeds nRF52833. For our application we need multiple timers enabled next to running ble. When we were doing integration tests we ran into the issue that we can't use timer1/timer2/timer3/timer4 utilizing the zephyr counter api if timer0 is not enabled in the device tree. It seems that timer initialization is done, but registered alarm callbacks are not executed. As soon as we enable timer0 in app.overlay everything works as intended. Unfortunately we can't do that because timer0 is used by the ble stack.

Are we doing anything wrong?

proj.conf, app,overlay and main.cpp for testing are attached below:

        

2376.app.overlay 4532.proj.conf0312.main.cpp

Best regards

Parents Reply Children
  • Hi,

     

    Thank you for uploading the files.

    Could you share what happens at your end? I'm unable to successfully recreate this scenario. I'm getting this output:

    *** Booting nRF Connect SDK v2.7.0-5cb85570ca43 ***
    *** Using Zephyr OS v3.6.99-100befc70c74 ***
    timer1 error: -134 - failed to set alarm on channel 2
    timer1 error: -134 - failed to set alarm on channel 3
    timer2 error: -134 - failed to set alarm on channel 2
    timer2 error: -134 - failed to set alarm on channel 3
    TIMER1 Channel: 0 Ticks: 500000
    TIMER1 Channel: 1 Ticks: 500000
    TIMER2 Channel: 0 Ticks: 500000
    TIMER2 Channel: 1 Ticks: 500000
    TIMER3 Channel: 0 Ticks: 500000
    TIMER3 Channel: 1 Ticks: 500000
    TIMER3 Channel: 2 Ticks: 500000
    TIMER3 Channel: 3 Ticks: 500000
    TIMER4 Channel: 0 Ticks: 500000
    TIMER4 Channel: 1 Ticks: 500000
    TIMER4 Channel: 2 Ticks: 500000
    TIMER4 Channel: 3 Ticks: 500000
    

     

    -134 = ENOTSUP and that occurs due to the number of CC channels, which is limited by the counter implementation with -2:

    https://github.com/nrfconnect/sdk-zephyr/blob/v3.6.99-ncs2/drivers/counter/counter_nrfx_timer.c#L18

     

    The (stripped) overlay file:

     

    // &timer0 {
    //     status = "okay";
    //     prescaler = <4>;
    // };
    
    &timer1 {
        status = "okay";
        prescaler = <4>;
    };
    
    &timer2 {
        status = "okay";
        prescaler = <4>;
    };
    
    &timer3 {
        status = "okay";
        prescaler = <4>;
    };
    
    &timer4 {
        status = "okay";
        prescaler = <4>;
    };
    
    

    And the build/zephyr/zephyr.dts shows that the timer0 is disabled:

    		timer0: timer@40008000 {
    			compatible = "nordic,nrf-timer";
    			status = "disabled";
    			reg = < 0x40008000 0x1000 >;
    			cc-num = < 0x4 >;
    			max-bit-width = < 0x20 >;
    			interrupts = < 0x8 0x1 >;
    			prescaler = < 0x0 >;
    		};

     

    Have I tested incorrectly? If yes, please have a look at my test here:

    331846.zip

     

    Kind regards,

    Håkon

  • Hi,

    that's interesting. Your test is correct. We recreated it and got the following output:

    We're using our own zephyr fork - maybe there are some compatibility issues between modules/packages. I will investigate it, thank you for your help!

  • Hi,

     

    Could you share which zephyr git hash you forked from?

     

    Kind regards,

    Håkon

Related