This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

EK-TM4C123GXL launchpad with SD Card

Other Parts Discussed in Thread: EK-TM4C123GXL

I am trying to interface SD Card with my Tiva Launchpad (EK-TM4C123GXL). I am using CCSv6 and the latest version of Tivaware. I have looked into your forums and have tried importing the DK_TM4C123G sdc_card program from Tivaware examples without any success.

I have commented out the display part and my basic program looks like this:

#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "inc/hw_memmap.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "driverlib/uart.h"
#include "utils/cmdline.h"
#include "utils/uartstdio.h"
#include "fatfs/src/ff.h"
#include "fatfs/src/diskio.h"

#include "fatfs/port/mmc-dk-tm4c123g.c"

static FATFS g_sFatFs;
static FIL g_sFileObject;

void
SysTickHandler(void)
{
    disk_timerproc();
}

void
ConfigureUART(void)
{
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
    ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
    ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
    UARTStdioConfig(0, 9600, 16000000);
    UARTStdioConfig(0, 9600, 16000000);
}

int main(void)
{
    int nStatus;
    FRESULT iFResult;

    ROM_FPULazyStackingEnable();
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                       SYSCTL_XTAL_16MHZ);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);

    power_on();
    ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / 100);
    ROM_SysTickEnable();
    ROM_SysTickIntEnable();
    ROM_IntMasterEnable();
    ConfigureUART();

    UARTprintf("\n\nSD Card Example Program\n");
    iFResult = f_mount(0, &g_sFatFs);
    if(iFResult == FR_INVALID_DRIVE)
    {
        UARTprintf("f_mount error\n");
        return(1);
    }
    else if(iFResult == FR_OK)
    {
    	UARTprintf("SD card found\n");
    	return(1);
    }
    else
    {
    	UARTprintf("nothing\n");
    	return(1);
    }
}

While building, it gives me errors like:

Description Resource Path Location Type
#10056 symbol "disk_initialize" redefined: first defined in "./main_1.obj"; redefined in "./third_party/fatfs/port/mmc-dk-tm4c123g.obj" sd_card C/C++ Problem

and similar errors for disk_read, disk_ioctl, etc.

Please tell me what I should do to make it work.

Thanks.

  • Hi,

    From the error message, your problem is defining C objects more than once. So, resolve the problem.

    I imported sd_card example program to my workspace, It build without errors, after changing the compiler version to the right one.

    - kel
  • If I remove the "power_on()" function call, it builds without errors. But the output obtained is wrong. Irrespective of whether my SD Card is connected or not, I always get the output as "SD card found".
    I thought that this problem arose because I couldn't find port initializations of Tiva anywhere in the FatFS include. Hence, I included mmc-dk-tm4c123g.c to do the same. But, whenever I do that, this redefining error arises.

    Can you please guide me through this?
  • Hi Moumita,

    I currently have no time to help you step by step. But, I saw some posts at E2E where they made the SD card example program work for Tiva Launchpad. Alternatively, ask help at TM4C forum. However, I would greatly advice you to do your homework first how to solve this before asking help there. You, can also do a search in the TM4C forum for "sd card" related post, and learn from it.

    - kel
  • I had posted this query after going through a lot of posts on the same.

    I wil go through the TM4C forum once again.

    Thanks for your time.