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

NRFX_SPI2_ENABLED or NRFX_SPIM2_ENABLED from SDK Config File

Hello,

I'd like to enable an instance of  SPIM2 master (base address: 40023000) in SDK 17.0.2  for SPI operations. In sdk_config.h, there are two options, NRFX_SPIM2_ENABLED and NRFX_SPI2_ENABLED. Which one do I use? Also, to further complicate things, there's a NRFX_SPIS2_ENABLED flag, which is what I don't what. 

This is for the NRF52840 chip.

Parents Reply Children
  • Sorry, might be my mistake, but if you plan to use nrf_drv_spi api then you can take a look at:
    \nRF5_SDK_17.0.2_d674dde\examples\peripheral\spi

    In that case the spi driver take use of SPI_ENABLED and SPI2_ENABLED defines from sdk_config.h. You can find that none of the NRFX_SPI* in sdk_config.h have any function in this case (you may try to simple find and replace NRFX_SPI if you like in sdk_config.h), the apply_config.h will simply undefine/overwrite all NRFX_SPI.

    If you want to use nrfx_spim directly you should instead look at:
    \nRF5_SDK_17.0.2_d674dde\examples\peripheral\nrfx_spim

    There you can also find that SPI_ENABLED and SPI2_ENABLED is not used at all, there is no apply_config.h, and all the NRFX_SPI* will have an effect. However you cannot use the nrf_drv api, you need to use the nrfx_spim* api. You will need to use the nrfx_spim_xfer() instead of nrf_drv_spi_transfer().

  • I want to use the NRFX driver and not the legacy one. In sdk_config.h, I made sure to set NRFX_SPIM2_ENABLED, and removed the legacy flags entirely. After having looked through the nrfx_spim example, I performed, what I believe, to be the necessary replacements in order to only use SPIM. 

    I get the following linker error when I build: 

    undefined reference to `nrfx_spim_init'. 

    I'm not sure exactly what's happening here except that the symbol nrfx_spim_init()
    is not recognized. Is apply_old_config.h still undefining SPIM items after I've updated
    sdk_config.h accordingly? I'm certainly missing something here.

    Thanks!

  • I suggest to study the \nRF5_SDK_17.0.2_d674dde\examples\peripheral\nrfx_spim examples, both in terms of which source and header files are included, and the defines in sdk_config.h 

    It likely will be a bit of trial and error approach.

    Kenneth

  • Hi Kenneth,

    Problem solved. nrfx_spim.c was not actually being compiled into my project. I had to manually include the translation unit into my .emProject file in Segger Embedded Studios. Code is up and running now.

Related