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.

TMS320F2812: SD card initialization problem

Part Number: TMS320F2812
Other Parts Discussed in Thread: CSD

Dear Sir/Madam,

I am using a F2812 based experimental kit. And my goal is to store the data, obtained from the ADC, to a sd card. Now while initializing the SD card i am facing some problem. The following code i am using for the SD card.

#include "SD.h"
#include "DSP281x_Device.h"
#include "DSP281x_Examples.h"


void spi_fifo_init(void);
Uint16 read_buffer[100], write_buffer[100];

//################################## MAIN ####################################
void main(void)
{
Uint16 i, testdata = 0x0000;

InitSysCtrl();

EALLOW;
SysCtrlRegs.HISPCP.all = 0x3; // HSPCLK = SYSCLKOUT/6

GpioMuxRegs.GPFMUX.all=0x000F; // Select GPIOs to be SPI pins

EDIS;

DINT;


InitPieCtrl();

IER = 0x0000;
IFR = 0x0000;

InitPieVectTable();

spi_fifo_init();

spi_initialization(); 

for(i=0;i<5;i++)
{
write_buffer[i] = testdata;
testdata += 0x0100; //Card accepts 8 bit data so upper 8 bits are used
// testdata = 0x0300;
}

sd_card_insertion(); //Check for card insertion
sd_initialization(); //Initialize card

sd_read_register(SEND_CSD); //Read CSD register
sd_read_register(READ_OCR); //Read OCR register
sd_read_register(SEND_CID); //Read CID register

for(;;)
{
sd_write_block(SECTOR_ZERO, write_buffer); //Write to sector specified
sd_read_block(SECTOR_ZERO, read_buffer); //Read from sector specified
}

}


void spi_fifo_init()
{
// Initialize SPI FIFO registers
SpiaRegs.SPIFFTX.all=0xE040;
SpiaRegs.SPIFFRX.all=0x204f;
SpiaRegs.SPIFFCT.all=0x0;
}


SPI Configuration is the following :

SpiaRegs.SPICCR.all =0x000F;
SpiaRegs.SPICTL.all =0x0006;
SpiaRegs.SPIBRR =0x007F;
SpiaRegs.SPICCR.all =0x008F;
SpiaRegs.SPIPRI.bit.FREE = 1; 

 

I am using the following sd card module:

www.amazon.in/.../ref=sr_1_8

Hardware connection is following :

MOSI(module)-->>MOSI(board) ; MISO(module)-->>MISO(board) ; CS(module)-->>SPISTEA(board) ; SCK(module)-->>SPICLKA(board) and Vcc and GND connection is done.


But while initializing then sd_error() is being called by sd_command_response(). In the following figure after sending response = spi_xmit_byte(DUMMY_DATA) the value of response = 9100. What does this value mean ?? I have also tried by changing the value of clock polarity in SPICCR (SpiaRegs.SPICCR.all =0x004F;) and clock phase in SPICTL (SpiaRegs.SPICTL.all =0x000E;). But everytime i am getting the same error while the value of response = 9100