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

  • Hi Karl,

    Is there anyone at Nordic who could help fix the linker file so that I can finally test the NAND Flash chip with your processor? This is the only thing outstanding for me to complete this project.

    Kind Regards,

    John

  • Hello John,

    john3909 said:
    Referencing preprocessor include folders in an external project isn't possible because of strict code review and traceability required for medical device certification.

    I am not familiar with the medical device certification process, but if it requires all the files to be located and ordered in a certain way then that certainly can be arranged.

    john3909 said:
    With Segger technical support, we started with your SPI example, and then added emFile files and we haven't got that working either

    What emFile files did you add, and where?
    You should add the modules/nrfx directory from the SDK to your existing project and make sure you set the correct sdk_config defines to utilize the drivers. 
    From the looks of the project files you supplied you have not configured any of the Section placement macros. Please have a look at this tutorial to see how that may be done.

    john3909 said:
    This makes no sense to me. For each peripheral, there are the primary HAL files and their associated dependent files. A simple script could copy these to a new project and update the GCC linker script file with a patch tool. As a minimum, you could just list the files and explain the changes needed for the GCC linker script file. This is not rocket science.

    Your previous comment stated that you would like an IDE where you could just "make the SPI function call and voila, I have SPI comms", without enabling and configuring the peripheral. I would argue that this request falls on it self when working with highly optimized low power SoCs. I suppose we just see these things very differently.

    I hope you have a great weekend,

    Best regards,
    Karl

  • Hello John,

    I have spoken with Dave and Belenie, and they have provided me with a summary of your project. I now have a far better understanding of your project.
    I will work on this today, to provide a project starting ground for you with the fatfs library using SPIM - my intention is to have this ready by the end of today or earlier.

    Hope you have a great day!

    Best regards,
    Karl

  • Hello again John,

    Attached to this message you will find a modified version of the fatfs example that uses SPIM instead of the legacy nrf_drv_spi driver.
    The modifications are made to the app_sdcard library, which implements the SPI SD card interface. The modified app_sdcard.c file is located next to the main.c of the project.

    The SD card instance is set to use SPIM3 in particular, which allows for 16 MHz SPI frequency(instead of the 8 MHz maximum of the other channels).
    If you are not using the nRF52840 SoC you will have to change the APP_SDCARD_SPI_INSTANCE in sdk_config to a SPIM instance between 0 - 2, as it is only the nRF52840 that has the SPIM3 instance.

    The example will in other ways behave as described in the fatfs example documentation.
    I tested it with an SD card here on my end and everything worked as expected.

    I hope this will satisfy your requirements for testing the SPIM module for use with the fatfs library.

    Please do not hesitate to let me know if you should encounter any more issues or questions!

    Best regards,
    Karl

    p1.15 SDC_SCK
    p1.13 SCD_MOSI
    p1.14 SDC_MISO
    p1.12 SDC_CS
    fatfs_nrfx_spim3.zip

  • Hi Karl,

    Thank you for all your help. The only problem I have is I still have to use Segger's emFile because I still need their NAND universal driver to talk to the Kiokia TH58CBG2S0HRAIJ part. I'll see if there is some of your code that I can adapt to make my Segger example work.

    Thank you again.

    Regards,

    John

Related