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

UNABLE TO GET fatfs_pca10028 EXAMPLE FROM nRF5_SDK_12.3.0 TO WORK ON nRF51822 BOARD

Hi All,

I am using the nRF51822 board and have it connected to a micro SD card shield using SPI.

I have not changed anything in the example file with the exception of redefining the pins in the main.c file to the following (according to the table here: http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v12.2.0%2Fapp_sdcard_example.html&cp=4_0_4_4_5_30):

#define SDC_SCK_PIN 29 ///< SDC serial clock (SCK) pin.
#define SDC_MOSI_PIN 25 ///< SDC serial data in (DI) pin.
#define SDC_MISO_PIN 28 ///< SDC serial data out (DO) pin.
#define SDC_CS_PIN 24 ///< SDC chip select (CS) pin.

The project builds with zero errors or warnings but upon loading, the following is output to PuTTY:

APP:INFO:
FATFS example.

APP:INFO:Initializing disk 0 (SDC)...
APP:INFO:Capacity: 30 MB
APP:INFO:Mounting volume...
APP:INFO:Mount failed.

I have tried using a different micro SD card but got the following output:

APP:INFO:
FATFS example.

APP:INFO:Initializing disk 0 (SDC)...
APP:INFO:Disk initialization failed.

I have taken a look at the following thread and tried lowering the SPI frequency to 125 kHz as recommended but the output was exactly the same for both SD cards.

https://devzone.nordicsemi.com/f/nordic-q-a/25951/sd-card-example-not-working-fine/102224#102224

The f_mount function seems to be returning "FR_INVALID_DRIVE". What could be causing this?

I have also read that the MOSI and SCK pins might need to be set to "high drive" according to this thread:

https://devzone.nordicsemi.com/f/nordic-q-a/34401/fatfs-example-does-not-work-with-every-sd-card/133317#133317

I added the following code before the fatfs_example() function in main.c in order to set the pins to "high drive" (although I'm not entirely sure this is correct):

nrf_gpio_cfg(SDC_SCK_PIN,
NRF_GPIO_PIN_DIR_OUTPUT,
NRF_GPIO_PIN_INPUT_DISCONNECT,
NRF_GPIO_PIN_NOPULL,
NRF_GPIO_PIN_H0H1, // Require High Drive low/high level
NRF_GPIO_PIN_NOSENSE);

nrf_gpio_cfg(SDC_MOSI_PIN,
NRF_GPIO_PIN_DIR_OUTPUT,
NRF_GPIO_PIN_INPUT_DISCONNECT,
NRF_GPIO_PIN_NOPULL,
NRF_GPIO_PIN_H0H1, // Require High Drive low/high level
NRF_GPIO_PIN_NOSENSE);

There was again no change to the output.

Any help would be greatly appreciated and please let me know if there is any other info I should provide.

Cheers,

~Brandon

Parents
  • Are you using an nRF51 DK? How have you wired the SD card shield to your device?

    A colleague of mine actually had one of those shields and I tested it with a KINGMAX 16GB SDHC card that I had laying around. It works fine for me if I connect VCC on the shield to 5V on the DK kit, but I get the "Disk initialization failed." if i connect it to Vdd on the DK:

    For the record: Your SD card shield comes with a 3.3 V voltage converter and voltage level shifter for the SPI signals, but Vdd on the nRF51 DK is typically closer to 2.9 V. So that means that your SD card operates at 3.3 V, but the nRF51 operates at ~2.9 V. This means that you are operating outside the Absolute maximum ratings of the nRF51 and you risk damaging it (max GPIO input voltage = Vdd + 0.3 V). If I were you I would modify your shield to bypass the 3.3 V voltage converter and supply the SD card with Vdd from the DK directly, or I would look for a shield without all the unnecessary components. I believe SD cards should be able to run at 2.9 V so you shouldn't need the voltage regulator or level shifter.

  • Thank you MartinBL! Turns out the problem was the BLE400 motherboard that I was using was only outputting ~3.1 volts from the 5V terminal, which was evidently too low. I powered the SD card shield from a separate 5 V supply and now it works perfectly.

Reply Children
No Data
Related