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

SPI, SPIM & SD card

HI

I'd like to clarify my understanding of how the three work-

  1. Does the SD card library use SPI or SPIM?
  2. Does SPIM automatically use EasyDMA, or is it configured? I see there is an option to select EDMA in sdk_config.h for the legacy SPI driver, but not in the SPIM driver section. It is possible that my sdk_config.h is malformed though as it's evolved from several of the example projects. I've attached it here.sdk_config.h
  3. Is SPIM using the same hardware (i.e. just an updated driver) or is it a seperate peripheral in the NRF52832? The docs say they use shared registers but not much else?
  4. Finally, is there a way to give my SPIM peripheral a higher IRQ priority than the SD card?

Thanks Slight smile

  • The docs say they use shared registers but not much else?

    For the application developer, this is a complex peripherial that can be configured as either SPI, SPIM, SPIS, TWI, TWIM or TWIS (and some instances only support SPI variants). You can select only ONE function.

    Does SPIM automatically use EasyDMA, or is it configured

    SPIM must use EasyDMA, as there is no other access to TX and RX data.

    Does the SD card library use SPI or SPIM?

    The needlessly? complex SD example uses nrf_drv_spi, which can be configured via sdk_config to be either, IIRC.

    It also had some bugs in the past - I usually use my own simpler diskio.c implementation for FATFS.

    And wheter you use SPI or SPIM is of almost no consequence. The FS code needs to wait for every transaction. Unless you run a really high interrupt load, there will be little speed difference between SPI and SPIM when talking to an SD card.

    The only instance where you wanted a SPIM for SD is the faster SPIM3 on NRF52840. Not available on the nrf52832, though.

  • OK thanks... it was mainly so I can get a better understanding of how things hang together.

    I do have a minor issue with my app which has SD -> ring buffer -> Timer -> SPIM -> DAC for playing audio, where access to the SD card interferes with either the timer or SPIM slightly... it manifests itself as a background buzz a little bit like mains hum.

    So yes I do have a pretty high interrupt load - I have the SoftDevice running, SD card access, timer ticking every 23us and a 24-bit SPIM transfer for every tick... hence the last question about IRQ priorities.

    Regards,

    Nick

  • is there a way to give my SPIM peripheral a higher IRQ priority than the SD card?

     I'm not sure I understand this question. The app_sdcard library uses the SPI/SPIM for interfacing with the SD card. Are you asking if you can set a second SPIM instance at a higher priority?

    The app_sdcard library uses the SPI_DEFAULT_CONFIG_IRQ_PRIORITY from the sdk_config.h file. If you want to set a different priority for a second SPIM instance, you can do that by changing the irq_priority parameter in the nrf_drv_spi_config_t struct when initializing the SPI driver instance.

Related