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
    1. What kind of SD card shield are you using?
    2. If you haven't done so already, can you set the log severity level to 'debug':
    3. It could be interesting to investigate the signal integrity and check whether the HW behaves as it should. Do you have an oscilloscope or logic analyzer that you can use to measure what goes on on the SPI bus?
    4. I suppose debugging what happens the very first time after powering up the board is difficult since the code has probably executed before you are able to attach the debugger?
Reply
    1. What kind of SD card shield are you using?
    2. If you haven't done so already, can you set the log severity level to 'debug':
    3. It could be interesting to investigate the signal integrity and check whether the HW behaves as it should. Do you have an oscilloscope or logic analyzer that you can use to measure what goes on on the SPI bus?
    4. I suppose debugging what happens the very first time after powering up the board is difficult since the code has probably executed before you are able to attach the debugger?
Children
No Data
Related