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

NRF52832 FatFS and other SPI slave devices

Hi,

I have built a prototype that has two SPI slave devices connected to it and it works perfectly. I have now tried to add an SPI SD card aswell by following the FatFS example in SDK 12.3 but this seems to be in conflict with my existing initialisation of the SPI bus. Specifically, the SPI bus is also initialised in app_sdcard.c and expects an explicit CS pin to be specified. With my code, I am handling CS myself in order to allow multiple slave devices. The specification of bus speed is also in conflict.

My questions:

What is the Nordic recommended way of supporting multiple SPI slave devices including an SD card on a single SPI bus?

Has anyone managed to get this working without modifying the SDK code?

Thanks! :)

Parents
  • Hi,

    I can't see any way you can solve this without modifying the SDK code. You could modify app_sdcard function app_sdc_init to take a SPI instance as parameter, and only initialize the SPI driver if this parameter is set to NULL, and else use the instance passed in the parameter. This would require you to relay the SPI instance through all blockdev function calls if you are using the FatFS example. You would also have to expose the spi_handler in app_sdcard through the header files, and relay SPI events related to SDCard, from default SPI handler to the app_sdcard spi_handler. app_sdcard also control CS pin manually, so his should not be conflicting with your other devices. The frequency of the SPI interface can be changed using the SPI HAL function nrf_spi_frequency_set().

    Do you not have more available serial instances for addind a separate SPI interface for the SD card? That would propably be the simplest solution.

    Best regards,

    Jørgen

  • What do you mean by separate SPI interface? Like a different SPI Bus with different MOSI/MISO/SCLK? Is there no easy way to share the same bus with SD card?

Reply Children
Related