Part Number: TMS320F28379D
Tool/software: Code Composer Studio
Hi Everyone,
I am use TMS320F28379D LaunchPadXL board . I want to store that data on SD card module . So, right now. I have gone through the SD card interfacing example available on CCS in sd_card.c,mmc_F2837x.c,ff.c
and this is my main code and Power_on setup mux-pin.I already change every SpicRegs to SpiaRegs in mmc_F2837x.c.Next I am try to use f_mount,f_open,f_write,f_close but nothing happen.Did i do something wrong? Can anyone please suggest me.I am new this is my first developkit.
Thank
int
main(void)
{
int nStatus;
FIL file;
WORD btw = 5;
FRESULT fresult;
WORD bw;
char buff[] = {'t','e','s','t','\n'};
//
// Initialize System Control
//
InitSysCtrl();
#ifdef _FLASH
//
// Copy time critical code and Flash setup code to RAM
// This includes the following functions: InitFlash();
// The RamfuncsLoadStart, RamfuncsLoadSize, and RamfuncsRunStart
// symbols are created by the linker. Refer to the device .cmd file.
//
memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
//
// Call Flash Initialization to setup flash waitstates
// This function must reside in RAM
//
InitFlash();
#endif
//
// Initialize interrupt controller and vector table
//
InitPieCtrl();
InitPieVectTable();
//
// Set the system tick to fire 100 times per second.
//
SysTickInit();
SysTickPeriodSet(SysCtlClockGet(SYSTEM_CLOCK_SPEED) / 100);
SysTickIntRegister(SysTickHandler);
SysTickIntEnable();
SysTickEnable();
//
// Enable Interrupts
//
IntMasterEnable();
//SPI-A Initial
power_on();
//FatFs
fresult = f_mount(0, &g_sFatFs);
if(fresult != FR_OK)
{
return(fresult);
}
fresult = f_open(&file, "Test.txt", FA_CREATE_NEW);
if(fresult != FR_OK)
{
return(fresult);
}
fresult = f_write(&file, buff, btw, &bw);
if(fresult != FR_OK)
{
return(fresult);
}
fresult = f_close(&file);
if(fresult != FR_OK)
{
return(fresult);
}
}
Power_on setup pin
void power_on (void) //EDITED
{
/*
* This doesn't really turn the power on, but initializes the
* SPI port and pins needed to talk to the SD card.
*/
EALLOW;
/* Enable the peripherals used to drive the SDC on SPI */
CpuSysRegs.PCLKCR8.bit.SPI_A = 1;
/*
* Configure the appropriate pins to be SPI instead of GPIO. The CS
* signal is directly driven to ensure that we can hold it low through a
* complete transaction with the SD card.
*/
//Unlock the SD-Card SPI GPIOs
GpioCtrlRegs.GPBLOCK.bit.GPIO58 = 0;
GpioCtrlRegs.GPBLOCK.bit.GPIO59 = 0;
GpioCtrlRegs.GPBLOCK.bit.GPIO60 = 0;
GpioCtrlRegs.GPBLOCK.bit.GPIO61 = 0;
//Set up MUX & DIR
GpioCtrlRegs.GPBMUX2.bit.GPIO61 = 0; //Leave as GPIO for manual CS control
GpioCtrlRegs.GPBGMUX2.bit.GPIO58 = 15;
GpioCtrlRegs.GPBGMUX2.bit.GPIO59 = 15;
GpioCtrlRegs.GPBGMUX2.bit.GPIO60 = 15;
GpioCtrlRegs.GPBGMUX2.bit.GPIO61 = 15;
GpioCtrlRegs.GPBMUX2.bit.GPIO58 = 15;
GpioCtrlRegs.GPBMUX2.bit.GPIO59 = 15;
GpioCtrlRegs.GPBMUX2.bit.GPIO60 = 15;
GpioCtrlRegs.GPBMUX2.bit.GPIO61 = 15;
GpioCtrlRegs.GPBDIR.bit.GPIO61 = 1;
//Set up GPIO Pull-up disables/enables
GpioCtrlRegs.GPBPUD.bit.GPIO58 = 0; //Needs to be normally pulled high
GpioCtrlRegs.GPBPUD.bit.GPIO59 = 0; //Needs to be normally pulled high
GpioCtrlRegs.GPBPUD.bit.GPIO60 = 0;
GpioCtrlRegs.GPBPUD.bit.GPIO61 = 0;
//Set up GPIOs in asynch mode
GpioCtrlRegs.GPBQSEL2.bit.GPIO58 = 3; // Asynch input
GpioCtrlRegs.GPBQSEL2.bit.GPIO59 = 3;
GpioCtrlRegs.GPBQSEL2.bit.GPIO60 = 3;
GpioCtrlRegs.GPBQSEL2.bit.GPIO61 = 3;
//Configure GPIOs for CPU1
GpioCtrlRegs.GPBCSEL4.bit.GPIO58 = 0;
GpioCtrlRegs.GPBCSEL4.bit.GPIO59 = 0;
GpioCtrlRegs.GPBCSEL4.bit.GPIO60 = 0;
GpioCtrlRegs.GPBCSEL4.bit.GPIO61 = 0;
//Lock the SD-Card SPI GPIOs
GpioCtrlRegs.GPBLOCK.bit.GPIO58 = 1;
GpioCtrlRegs.GPBLOCK.bit.GPIO59 = 1;
GpioCtrlRegs.GPBLOCK.bit.GPIO60 = 1;
GpioCtrlRegs.GPBLOCK.bit.GPIO61 = 1;
EDIS;
/* Deassert the *** chip selects for both the SD card and serial flash */
DESELECT();
/* Configure the SPI C port */
SpiaRegs.SPICCR.bit.SPISWRESET = 0; //Set reset bit low
SpiaRegs.SPICTL.bit.CLK_PHASE = 0;
SpiaRegs.SPICCR.bit.CLKPOLARITY = 1;
SpiaRegs.SPICTL.bit.MASTER_SLAVE = 1; //Master mode
SpiaRegs.SPIBRR.all = 63; //update value to proper setting for correct bitrate ( current: ~500kHz)
SpiaRegs.SPICCR.bit.SPICHAR = 0x7; //Set char length to 8 bits
SpiaRegs.SPICTL.bit.TALK = 1;
SpiaRegs.SPICCR.bit.SPISWRESET = 1; //Release SPI from reset
SpiaRegs.SPIPRI.bit.FREE = 1;
SpiaRegs.SPIPRI.bit.SOFT = 1;
/* Set DI and CS high and apply more than 74 pulses to SCLK for the card */
/* to be able to accept a native command. */
//send_initial_clock_train();
//DELAY_US(50);
PowerFlag = 1;
}
https://www.ti.com/tool/LAUNCHXL-F28379D Developkit

