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

I'm using the Segger nRF52840-DK and I want to add support for SPI?

I'm using the nRF52840-DK evaluation software from Segger. I want to add NAND Flash support, so I want to add an SPI interface. I have looked at the example in nRF5SDK160098a08e2 and that works nicely on my board, but I'm having difficulty moving that SPI example to the nRF52840-DK project as there are dependencies on Integration, module and components folders. isn't there a much simpler way to just add SPI support like there is when using ST Micro Cube IDE? I did manage to have a successful build with nrfx version of SPI, but the driver won't work correctly on my board.

I'm using the latest version of Segger Embedded Studio.

Regards,

John

  • Hello John.

    Sorry for my delayed reply.

    john3909 said:
    Let's make this simple. Start a new nRF52840 project with all the default settings. Show me how you add the required code to support for comms with an SPI device. Assume that no SPI example project existed.

    In essence you are asking me to type out the nrfx SPIM example here, to avoid linking you an example. This example demonstrates the nrfx_spim driver, and the main file comes in at 80 lines of code - but I recon that it might be the sdk_config file you are interested in hearing more about? Is there a particular part of the example code you would like me to go through or explain in detail?

    The nrfx SPIM API Reference and the SPIM peripheral documentation are good starting points when adding SPIM to an existing project, though I suspect you have already seen them.

    Note that the SPIM driver uses easyDMA, and if you do not intend to use this, you should use the nrfx_spi driver instead.

    Best regards,
    Karl 

  • Hi Karl,

    OK, so there are several things that go into adding SPI into a project.

    Setting up the clock for the SPI peripheral, setting up pin configuration, enabling the SPI peripheral, setting up the SPI registers, etc. In ST Micro, I don't have to do any of this, it is done automatically for me. All I do is make the SPI function call and viola, I have SPI comms. My question is, do I have to do all the low level grunt work, or is there a much simpler way to get SPI comms working with Segger Embedded Studio on a nRF52840 platform?

    Regards,

    John

  • Sorry, when I replied, there was no reply button at this level, so I could only reply up one level.

  • What are the minimum number of files (driver/library/support) that need to be added to the project to get SPI working. I haven't had to work at this level for many years. Am I missing something, or is the Nordic development environment so backward that I have to figure out what support files are needed to get my application to communicate of SPI?

    Regards,

    John

  • So let me give you an example of how crazy this is. I start by copying

    modules/nrfx/drivers/include/nrfx_spi.h

    modules/nrfx/drivers/include/nrfx_spim.h

    modules/nrfx/drivers/src/nrfx_spi.c

    modules/nrfx/drivers/src/nrfx_spim.c

    modules/nrfx/hal/nrf_spi.c

    modules/nrfx/hal/nrf_spim.c

    The I add the following to the preprocessor include directories

    $(ProjectDir)/../../../modules/nrfx/drivers

    $(ProjectDir)/../../../modules/nrfx/drivers/include

    $(ProjectDir)/../../../modules/nrfx/hal

    I do a build and get a compile error nrfx.h is missing

    I add the following to the preprocessor include directories

    $(ProjectDir)/../../../modules/nrfx

    I build again, and I get a compile error nrfx_config.h is missing

    Do you see how crazy this is???? There has to be a much simpler way, but I just don't see it.

    Regards,

    John

Related