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

SPIM3 initialization issue

Hello guys,

I am using nRF52840 and SDK 15.3.0. Trying to use SPIM3 device because of the speed.

In my sdk_config.h file, I set both NRFX_SPIM_ENABLED and NRFX_SPIM3_ENABLED.

However, when I try to initialize SPIM3 with

err_code = nrfx_spim_init(&_spi_handle, &spi_config, NULL, NULL);

I get the error "undefined reference to `nrfx_spim_init`". This error comes because in nrfx_spim.c file, this pre-processor check returns false:

#if NRFX_CHECK(NRFX_SPIM_ENABLED)

I wonder why NRFX_CHECK(NRFX_SPIM_ENABLED) returns false when NRFX_SPIM_ENABLED is set inside sdk_config.h? Do you guys have any idea?

Thanks in advance for your time and effort.

Sincerely,

Bojan.

Parents
  • Hello Bojan,

    If NRFX_CHECK(NRFX_SPIM_ENABLED) returns false, then it means that NRFX_SPIM_ENABLED is defined to 0. Although you have defined it to 1 in sdk_config.h, it may be redefined in apply_old_config.h, which is a backwards compatibility header file. 

    Basically, if you define NRFX_SPIM_ENABLED 1 and NRF_SPIM_ENABLED 0, then NRFX_SPIM_ENABLED will be set to 0. So either:

    1: Define NRFX_SPIM_ENABLED to the same as NRF_SPIM_ENABLED

    2: Delete the NRF_SPIM_ENABLED define (not just set it to 0, but remove it). 

    3: Remove the apply_old_config.h file from your project. 

    Best regards,

    Edvin

  • I find this to be a constant source of problems & confusion - both myself and in posts by others here on the forum.

    It is particularly hard to debug because of the way everything is hidden in multiple layers of macro definition, redefinition and preprocessor tricks with the ## operator, etc.

    Disappointed

    This really needs to be far better documented!

Reply Children
Related