undefined reference to `nrfx_timer_enable'

I am using SDK 14.2.0 with Segger IDE.

I am trying to configure timers and while my code does compile w/o errors the linker fails with message in the subject above.

To avoid copy_old_config script re-writing my sdk_config.h I have modified my sdk_config.h:

//#ifndef TIMER_ENABLED
//#define TIMER_ENABLED 0
//#endif

According to support threads it is good practice to remove or comment-out the legacy driver defines in sdk_config.h.

The code compiles fine because of the following line in nrf_drv_timer.h:

#define nrf_drv_timer_enable                     nrfx_timer_enable

The issue is there is no function named nrfx_timer_enable anywhere in the sdk code base that I can find.

Seeger IDE list of nRF_Drivers has no file specified for timer support.

I added SDK_v14_2_0\components\drivers_nrf\timer\nrf_drv_timer.c but this did nothing.

Maybe sdk is missing the nrfx compatible driver? nrfx_timer.c?

Any ideas what is wrong here?

sdk_config.h is attached.

2620.sdk_config.h

  • Hi,

    Maybe sdk is missing the nrfx compatible driver? nrfx_timer.c?

    Yes. It looks like you are mixing SDK versions here, as nrfx was introduced in SDK 15.0.0. So there is no wonder nrfx_timer_enable etc. does not exist. You will find most of the same functionality in SDK 14.2 as well though, but using only nrf_drv_* and not nrfx_*.

  • Thanks for the info. Did not know nrfx was not supported in sdk 14.2.

    In the image above you can see we have nrfx_spim driver included and the spi interfaces work with this code.

    I updated sdk_config.h to enable legacy timers:

    // <e> TIMER_ENABLED - nrf_drv_timer - TIMER periperal driver - legacy layer
    //==========================================================
    #ifndef TIMER_ENABLED
    #define TIMER_ENABLED 1
    #endif

    #ifndef TIMER0_ENABLED
    #define TIMER0_ENABLED 1
    #endif

    I enabled al four timers.

    My app #include "nrf_drv_timer.h" now.

    Link still fails with "undefined reference to `nrfx_timer_enable'", undefined reference to `nrfx_timer_init', 

    Even with sdk_config.h timer configuration updated to use legacy timer support the code is being built with references to nrfx support.

    nrf_drv_timer.h still does this:

    #define nrf_drv_timer_enable  nrfx_timer_enable

    That  does not look right to me. Why is it remapping nrf_drv_timer_enable to nrfx_timer_enable if nrfx is not supported?

    2451.sdk_config.h

  • I also notice nrf_drv_timer.h file being used is located at ..sdk\integration\nrfx\legacy.

    Is this some sort of shim layer to allow older sdk versions use the newer nrfx code? That folder does not contain a .c file for the timer either.

    How do I use this integration layer correctly with timers?

  • Hi,

    davidb said:

    I also notice nrf_drv_timer.h file being used is located at ..sdk\integration\nrfx\legacy.

    Is this some sort of shim layer to allow older sdk versions use the newer nrfx code?

    Yes. SDK 15.0.0 introduced the nrfx drivers, which were mostly the old nrf_drv drivers but without any dependencies on the SoftDevice (which  a few had), to have a generic driver package that could be used in other projects as well (like Zephyr). The nrf_drv API was still kept though.

    davidb said:
    How do I use this integration layer correctly with timers?

    But please note that this did not exist before 15.0.0, so as you are referring to code that does not exist in 14.2 while stating that you use it, I am not sure what you are doing. Have you copied in code from newer SDKs or other SW components written for newer SDKs? Please elaborate on this. With that in mind, the integration layer is only relevant for SDK version >= 15.0.0, and in that case you can refer to for instance the Timer Example. Also, if you compare that with the SDK 14.2 timer example you will see that the example code is essentially the same, but in that case there is no nrfx and integration layer (shim).

  • I fixed the issue. ..sdk\modules\nrfx\drivers\src\nrfx_timer.c was not included in the solution. I added the fie and timer functions are seen in debugger. no more linker errors.

Related