Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

"NRFX_SPI0_INST_IDX" is undefined (IAR)

Hi,

Can't get rid of compilation error about undefined NRFX_SPI0_INST_IDX after adding nrfx_spi driver. Searched the forums and found similar issues but none of the suggested actions seems to work for me. The steps taken to add the driver:

  1. nrfx_spi.c added to project
  2. #define NRFX_SPI_ENABLED 1 and #define NRFX_SPI0_ENABLED 1 in sdk_config.h
  3. Include file search paths updated as far as I can tell (no complaints about missing files)

Using a very similar configuration for TWI/TWI0 which I managed to get working. I had issues with this as well but managed to solve it by defining TWI_ENABLED 1 and TWI0_ENABLED 1 as well. The corresponding thing does not work with SPI though.

Using IAR compiler and SDK 15.0.0, nRF52832

BR

/Ola

  • Hi,

    Try also enable this:

    and make sure that no others peripherals (as far as I know at least TWI) lays on same instance.

    I.e. if you defined SPI on 0, other (TWI) have to be on 1.

    Also make sure you added next file to project:

    nrf_drv_spi.c 

    Regards

  • Thank you for your reply, I've tried all suggestions. Unfortunately, no success. Still complaining about the undefined SPI instance (except it's NRFX_SPI1_INST_IDX now after moving to another instance).

    It might be some IAR related thing that affect expansion of NRFX_CHECK macro? ... but still the same construction is used and is working for TWI. I'm puzzled...

  • You need to enable SPI0 for both the legacy and nrfx driver in sdk_config.h

  • Yes, this was what I tried to do (except I now use SPI1).

  • I suggest you open the SPI example from SDK15 and compare the included files and sdk_config to your project. 

1 2