I want to interface SD card with my EK-TM4C123GXL Tiva launchpad. I went through many of the posts on the same, and many of them suggested to start from the Tivaware example of SD card interfacing with the DK-TM4C123GXL launchpad. Taking help from that example, I made a basic code to test of the SD card is present or not as follows:
#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/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 the following errors:
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.
I am unable to understand why there the multiple inititalizations are happening in spite of making sure that there is only one instance. I am using CCSv6.
Can anyone help me with this? I am stuck on SD card interfacing since a long time. Please guide me through this.
Thank you.