SD card interfacing

Hi,

I have written SD & SDHC card routine for reading, writing and erasing data from SD card. It used the hardware SPI of nRF51822.

NOTE:

1)Define the PINs of SD card first before initialing.

2)Define MOSI, MISO and SCK pins only, define the CS pin to some other pin that is not being used( these pin are define in spi_master_config.h )

3)CS pin should be separately define in SD_Routines.c by the name #define MMCSD_PIN_SELECT 29

4)If you are facing problem in using my library then first test you SPI separately.

SD_Routines.c SD_Routines.h

  • Great library Kumar (and of course you Salman). Do you mind making a new blog with link to this code which uses the filesystem? This would make it easier for people to see it. Have a link to this for the hardware connections.

    I had problems when using nRF52, which was caused by this errata. The solution was to use SPI0 instead of SPIM0 (#define SPI0_USE_EASY_DMA 0). Implementing the workaround should also work.

  • In case anybody still require FAT system, I've put it here

  • Hello people,

    I'm using the NRF52 PCA 10040 (S132) devkit for some time now and I've soldered a micro SD card holder to 4 pins configured as SPI using SDK 11 with the code above. The DO has a 16k ohm pull-up to VDD, no other pins have pull-up or down. Whatever I do using this example code or different example code variants found all over the net, I do not get any level change of the card on the DO pin. I even used a different SD card holder connected to a different set of pins, use SPI 0, 1 and 2 controller, different delays, 125 and 250 kHz, SPI mode 0-3, different CS toggle initialization strategies, sending extra idle clocks, 4 different SD cards of 2, 8 and 16 GB, all different brands, no change on DO whatsoever. I've ordered some more SD cards of different brands to test with in the next couple of days but have little hope this will bring me closer to a solution. One thing I've noticed is that the NRF52 only supplies 2.8-2.9 volts on VDD or any other output pin. I've therefore used an external 3.3V power supply and sent CMD8 as initialization and saw a reply from the card on the DI channel, making it kind of bi-directional...

    Hope anyone has a clue ? Kind regards, Bart.