This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF_CLOCK_ENABLED not found when compliling nrf_drv_clock.c

With SES, I'm trying to build an app which includes nrf_drv_clock.h. There are two functions declared there that I call in my own main.c:

  - nrf_drv_clock_init()

  - nrf_drv_clock_lfclk_request(NULL)

Specifically, as follows:

static void lfclk_request(void)
{
    ret_code_t ret;
    if( (ret = nrf_drv_clock_init()) != NRF_SUCCESS )
      printf("nrf_drv_clock_init failed, ret=%d\n", ret);

    nrf_drv_clock_lfclk_request(NULL);
}

Now, as a newbie, I'm banging my head against a wall.

I have nrf_drv_clock.c in my project, as I think I should, but when building the code, then comes the error

1> Diagnostics:
1>   error: undefined symbol: nrf_drv_clock_init
1>   error: undefined symbol: nrf_drv_clock_lfclk_request
Build failed

It seems that the problem pinpoints to the following in nrf_clock.c, as lines below it are greyed in SES:

#include <nordic_common.h>
#include "nrf_drv_clock.h"

#if NRF_MODULE_ENABLED(NRF_CLOCK)

To me, this contradicts with my sdk_config.h that apparently has NRF_CLOCK_ENABLED

// <e> NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver - legacy layer
//==========================================================
#ifndef NRF_CLOCK_ENABLED
#define NRF_CLOCK_ENABLED 1
#endif

(Actually, I don't find any path, how the compilation of nrf_drv_clock.c could even thoretically include my sdk_config.h - and the definition.)

What am I doing wrong?

  • I think you are on the right track, it looks like #define NRF_CLOCK_ENABLED 1
    in your sdk_config.h isn't being seen when nrf_drv_clock.c is being compiled.  Why not confirm that the sdk_config.h file you are editing really is the file being used at compile-time, perhaps insert a line like this and see if it immediately causes your compile to break:

    #ifndef NRF_CLOCK_ENABLED
    #error is this happening??? NRF_CLOCK_ENABLED 1
    #define NRF_CLOCK_ENABLED 1

    If this doesn't cause the compilation to break, some other sdk_config file elsewhere is being used instead.  In this case check the preprocessor include directories (in the Project Explorer tab, right click on your project and choose "Options", then view the "Preprocessor" settings in configuration "Common" or "Debug" or "Release"; there should be a pathname to the directory in which your sdk_config.h file lives)

    BTW "nrf_drv_clock.h" includes <nrfx.h> which includes <nrfx_config.h> which includes <sdk_config.h>

  • Many thanks, Daniel, for the prompt response!

    Indeed, it fails when compiled

    --

    I have sdk_config.h in my project directory, together with my main.c. I guess this is the first path that the compiler checks? If <sdk_config.h> would eventually be included, but its path not found, then I'd expect an error for that...

    (However, to double-check, I now added my project directory to be first in the include path list: no difference.)

    --

    "nrf_drv_clock.h" includes <nrfx_clock.h> which includes <nrfx.h> which does NOT include <sdk_config.h> in my config.

    The closest match I see is that <nrfx.h> includes <nrfx_config.h> and <nrfx_glue.h>, but neither of them see <sdk_config.h>

    Something is obviously wrong.

  • Hi Wille, 

    Did you add the directory \nRF5_SDK_15.3.0_59ac345\integration\nrfx\legacy into User Include Directories for nrf_drv_clock.h as the Including header files documentation?

    -Amanda H.

  • Hi Amanda,

    Thank you for your reply!

    I guess I have it correctly: the directory is in 'system include directories' of the project.

    nrf_drv_clock.c also under the project.

    Furthermore, the configuration snippet above is from Debug configuration, and I'm trying to build in Debug. (I'm not touching Debug/Release at all at this point.)

    The question still remains a mystery... :^/

  • Hi Wille, 

    Please try to enable nrfx_clock as

    // <e> NRFX_CLOCK_ENABLED - nrfx_clock - CLOCK peripheral driver
    //==========================================================
    #ifndef NRFX_CLOCK_ENABLED
    #define NRFX_CLOCK_ENABLED 1
    #endif

    Please let me know this can work or not. Thanks.

    -Amanda H.

Related