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

nRF52810 and SPIM configuration

I'm new to both the nRF52 family and SPI, and I'm working on an SPI master nRF52810 (using the PC10040e setup). I'm compiling using GCC and makefiles. I've set NRFX_SPIM_ENABLED and NRFX_SPIM0_ENABLED in the config, and I've got a setup declaration like this:

    #define SPI_INSTANCE 0
    static const nrfx_spim_t spi = NRFX_SPIM_INSTANCE(SPI_INSTANCE);
    

When I try to compile this, I get the errors

In file included from ../../../../nRF5_SDK_15.0.0_a53641a/modules/nrfx/nrfx.h:45:0,
from ../../../../nRF5_SDK_15.0.0_a53641a/modules/nrfx/drivers/include/nrfx_spim.h:44,
from ../../../peripheral.c:8:
../../../../nRF5_SDK_15.0.0_a53641a/modules/nrfx/drivers/include/nrfx_spim.h:93:35: error: 'NRFX_SPIM0_INST_IDX' undeclared here (not in a function); did you mean 'NRFX_SPIM_INSTANCE'?
.drv_inst_idx = NRFX_CONCAT_3(NRFX_SPIM, id, _INST_IDX), \
^
../../../../nRF5_SDK_15.0.0_a53641a/modules/nrfx/drivers/nrfx_common.h:117:37: note: in definition of macro 'NRFX_CONCAT_3_'
#define NRFX_CONCAT_3_(p1, p2, p3) p1 ## p2 ## p3
^~
../../../../nRF5_SDK_15.0.0_a53641a/modules/nrfx/drivers/include/nrfx_spim.h:93:21: note: in expansion of macro 'NRFX_CONCAT_3'
.drv_inst_idx = NRFX_CONCAT_3(NRFX_SPIM, id, _INST_IDX), \
^~~~~~~~~~~~~
../../../peripheral.c:32:32: note: in expansion of macro 'NRFX_SPIM_INSTANCE'
static const nrfx_spim_t spi = NRFX_SPIM_INSTANCE(SPI_INSTANCE);
^~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
../../../../nRF5_SDK_15.0.0_a53641a/components/toolchain/gcc/Makefile.common:272: recipe for target '_build/nrf52810_xxaa/peripheral.c.o' failed

On investigation, it looks almost as if NRFX_SPIM0_ENABLED is getting undefined somewhere. Now, there's a load of stuff in the pca10040a config file which looks like it has to do with legacy SPI. If I comment all that SPI config out  - everything from SPI_ENABLED down to SPI0_ENABLED, removing those definitions entirely - it compiles.

I'm a bit concerned that I'm not sure why this is happening - I'm not at the stage where I'm testing anything with hardware yet, and I don't want to plug hardware in and puzzle over why it's not working when I've inadvertently disabled something with this mass commenting out in sdk_config.h. Is it safe (and required) for me to comment all that stuff out?

Thanks,

Jim

  • Hello,

    I would say that you are pretty much spot on:

    "On investigation, it looks almost as if NRFX_SPIM0_ENABLED is getting undefined somewhere."

    If you search in your project, you should fine a file called "apply_old_config.h" which does exactly this.

     

    I believe it is included in most projects for porting reasons. However, it is quite confusing when you start with SDK15.

     

    The solution is to:

    1. Either remove all legacy defines from sdk_config.h. Make sure to not remove the defines that doesn't have an NRFX implementation, that you want to use.

    2. remove the apply_old_config.h file (make sure that the project doesn't include it). It is included from the file "nrfx_glue.h".

     

    If you look at the file, apply_old_config.h, you will understand what it does, and why you get the behavior that you see.

     

    Best regards,

    Edvin

  • OK, thanks - so the legacy stuff, when set, overrides the other stuff. I think I'll stick with commenting out legacy stuff in my sdk_config for now; I don't want to mess up other things by removing apply_old_config.h.

Related