Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Communicating with SD card using spi but no data Receive from SD Spartan 3

Status
Not open for further replies.

pic+gsm

Newbie level 4
Newbie level 4
Joined
Nov 24, 2012
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,324
Hello people can someone please help me I am trying to communicate with SD card using Spartan 3 am trying to use the SPI from Xilinx, does anyone have example of SPI or tutorials
The problem is when I send the CMD0 command there is no respond.
But I know it’s working because When I used this https://stevenmerrifield.com/tools/sd.vhd it works with ISE, now I am trying to use microblaze but facing this problem I can’t receive nothing from SPI
Thank you
 

Hello people can someone please help me I am trying to communicate with SD card using Spartan 3 am trying to use the SPI from Xilinx, does anyone have example of SPI or tutorials
The problem is when I send the CMD0 command there is no respond.
But I know it’s working because When I used this https://stevenmerrifield.com/tools/sd.vhd it works with ISE, now I am trying to use microblaze but facing this problem I can’t receive nothing from SPI
Thank you
It's not at all clear what you are asking help on. You haven't posted any code but a link to some working test code that writes and reads from an SD card. You don't tell us how you're connecting the SPI to the microblaze or what you are doing to send the CMD0 command.
 

Hi ads-ee thank you for your reply
I made it work there is a response from the sd card now my problem I am initialising the sd but I can’t read a block from it can you please advise me on my code?

Code:
int wait_data(void){
	SelectChip();
	WriteBuffer[0] = 0xFF;
	WriteBuffer[1] = 0xFF;
	WriteBuffer[2] = 0xFF;
	WriteBuffer[3] = 0xFF;
	WriteBuffer[4] = 0xFF;
	WriteBuffer[5] = 0xFF;
	WriteBuffer[6] = 0xFF;
	WriteBuffer[7] = 0xFF;
	WriteBuffer[8] = 0xFF;
	WriteBuffer[9] = 0xFF;



	XSpi_Transfer(&LCD_SpiInstance, WriteBuffer , NULL, 10);
	XSpi_Transfer(&LCD_SpiInstance, WriteBuffer, ReadBuffer, 10);
	DeselectChip();
	return ReadBuffer[0];
}

void SD_read(unsigned long sector, unsigned short offset, unsigned char * buffer, unsigned short len) {
	unsigned short i, pos = 0;

	SelectChip();

	xil_printf("SD_read");
	WriteBuffer[0] = 0xff;
	WriteBuffer[1] = 0x51;
	WriteBuffer[2] = (sector>>15); //Argument[31..24]
	WriteBuffer[3] = (sector>>7); //Argument[23..16]
	WriteBuffer[4] = (sector<<1); //Argument[15..8]
	WriteBuffer[5] = 0x00;   //Argument[7..0]
	WriteBuffer[6] = 0xff;

	XSpi_Transfer(&LCD_SpiInstance, WriteBuffer, NULL, 8);
		ILI9340_DeselectChip();
	for(i=0; i<10 && wait_data() != 0x00; i++) {} // wait for 0
	
	for(i=0; i<10 &&  wait_data() != 0xFE; i++) {} // wait for data start

	for(i=0; i<offset; i++) // "skip" bytes
		XSpi_Transfer(&LCD_SpiInstance, 0xFF, ReadBuffer, offset);

	for(i=0; i<len; i++){ // read len bytes
		XSpi_Transfer(&LCD_SpiInstance, 0xFF, ReadBuffer, len);
		buffer[i] = ReadBuffer[i];
	}
	for(i+=offset; i<512; i++) // "skip" again
		XSpi_Transfer(&LCD_SpiInstance, 0xFF, ReadBuffer, 8);

	// skip checksum
	wait_data();
	wait_data();

	DeselectChip();
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top