For some time I have been trying to write in an SD card, using the EK-TM4C123GXL and CCS_6.1.2.00015.
Ti-RTOS has woked but i dont really want to use the SYS/BIOS part, so now I am trying to make work an aplication that use the FatFs APIs but is being really dificult and i would extremly appreciate your help to build it. Any advice is helpful.
My host is windows 7
Te Code I am trying to run is this:
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_ssi.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
#include "driverlib/ssi.h"
#include "ff.h"
#include "diskio.h"
FATFS sdVolume;
FIL logfile;
uint16_t fp;
//*****************************************************************************
//
// Configure the UART and its pins. This must be called before UARTprintf().
//
//*****************************************************************************
void
ConfigureUART(void)
{
//
// Enable the GPIO Peripheral used by the UART.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
//
// Enable UART0
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
//
// Configure GPIO Pins for UART mode.
//
ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//
// Use the internal 16MHz oscillator as the UART clock source.
//
UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
//
// Initialize the UART for console I/O.
//
UARTStdioConfig(0, 115200, 16000000);
}
void fatalError(char errMessage[]){
UARTprintf(errMessage);
while(1);
}
//*****************************************************************************
//
// Main 'C' Language entry point.
//
//*****************************************************************************
int
main(void)
{
uint32_t ui32Data;
//
// Setup the system clock to run at 40 MHz from PLL with crystal reference
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
SYSCTL_OSC_MAIN);
//
// Initialize the UART.
//
ConfigureUART();
//
// Print the welcome message to the terminal.
//
//UARTprintf("\033[2JNew example\n");
ROM_SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
SYSCTL_OSC_MAIN);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
//UARTprintf("Configurando SPI\n");
ROM_GPIOPinConfigure(GPIO_PA2_SSI0CLK);
ROM_GPIOPinConfigure(GPIO_PA3_SSI0FSS);
ROM_GPIOPinConfigure(GPIO_PA4_SSI0RX);
ROM_GPIOPinConfigure(GPIO_PA5_SSI0TX);
ROM_GPIOPinTypeSSI(GPIO_PORTA_BASE,GPIO_PIN_5|GPIO_PIN_4|GPIO_PIN_3|GPIO_PIN_2 );
SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_1, SSI_MODE_MASTER, 10000, 16);
SSIEnable(SSI0_BASE);
UINT bw;
switch(f_mount(&sdVolume, "", 0)){
case FR_OK:
UARTprintf("SD Card mounted successfully\n");
break;
case FR_INVALID_DRIVE:
fatalError("ERROR: Invalid drive number\n");
break;
case FR_DISK_ERR:
fatalError("ERROR: DiskIO error - Check hardware!\n");
break;
case FR_NOT_READY:
fatalError("ERROR: Medium removal or disk_initialize\n");
break;
case FR_NO_FILESYSTEM:
fatalError("ERROR: No valid FAT volume on drive\n");
break;
default:
fatalError("ERROR: Something went wrong\n");
break;
}
if(f_open(&logfile, "PRUEBA.txt", FA_WRITE | FA_OPEN_ALWAYS) == FR_OK) { // Open file - If nonexistent, create
f_write(&logfile, "Texto de prueba\n", 16, &bw);
//UARTprintf("El archivo pesa: %u\n",logfile.fsize);
f_close(&logfile);
}
while(1)
{
ui32Data = 156;
SSIDataPut(SSI0_BASE, ui32Data);
while(SSIBusy(SSI0_BASE));
}
}
The problem i got are:
<Linking>
undefined first referenced
symbol in file
--------- ----------------
IntGPIOb ./startup_ccs.obj
MPU9150I2CIntHandler ./startup_ccs.obj
disk_initialize ./ff.obj
disk_ioctl ./ff.obj
disk_read ./ff.obj
disk_status ./ff.obj
disk_write ./ff.obj
get_fattime ./ff.obj
error #10234-D: unresolved symbols remain
error #10010: errors encountered during linking; "Comunic_SPI.out" not built
>> Compilation failure
gmake: *** [Comunic_SPI.out] Error 1
gmake: Target `all' not remade because of errors.