Discussion in "8051 Discussion Forum" started by    duncan    Aug 3, 2008.
Sun Aug 31 2008, 06:40 am
#11
l am using 22.1184MHz for crystal clock frequency...
Tue Sep 02 2008, 02:07 am
#12
you can set the clock divisor for baudrate generator to Fosc/8 ( 010) in SPCON register of ED2.
more information check page 65 of datasheet.
Fri Sep 05 2008, 05:37 pm
#13
i m sorry,Ajay..but i m still very confuse how to calculate the SPI clock frequency

SPI clock frequency = baud rate?

according to the data sheet,

baudrate = Fclk periph / baud rate divisor

Fclk periph = Fosc/[4*(255-CKRL)]

do we need to set the CKRL?


[ Edited Fri Sep 05 2008, 05:39 pm ]
Fri Sep 05 2008, 05:50 pm
#14
i couldnt initialize my sdcard
is my sd card initialization steps correct?

unsigned char InitSD()
{
	int i;
	unsigned char status;
	
	SPI_set_speed (128);	//Set SPI speed to below 400khz
	
	CS= SD_OFF;			//assert sd card
	
	for(i=0; i<10; i++)	//delay minimum 74clock; 10 X 8byte = 80clock cycle
	{
		SPI_transmit(0xFF);
	}
	
	CS = SD_ON;			//deassert sd card
	
	for(i=0; i<3; i++)	//delay minimum 16 clock; 3x8 =24 clock
	{
		SPI_transmit(0xFF);
	}
	
	// Wait for the SD Card to go into IDLE state
	
	
	for(i=0;i<=50;i++)
	{
		status = SD_WriteCommand(CMD0_GO_IDLE_STATE);	
		
		if(status == 0x01) 
			break;
		
		if(i==50) 
			return 1;
	}
	
	// Wait for SD Card to initialize
	
	for(i=0;i<=50;i++)
	{
		status = SD_WriteCommand(CMD1_SEND_OP_COND);
		
		if((status & R1_IN_IDLE_STATE)==0)	//card initialization is completed and wait for next command
			break;
		
		if(i==50) 
			return 2;
	}
	
	for(i=0;i<=50;i++)		// Send the ACMD41 command to initialize SD Card mode (not supported by MMC cards)
	{
		status = SD_WriteCommand(ACMD41_SD_SEND_OP_COND);
		
		if((status & R1_IN_IDLE_STATE)==0)	 // Might return 0x04 for Invalid Command if MMC card is connected
			break;
		
		if(i==50) 
			return 3;
	}
	
	status = SD_WriteCommand(CMD55_APP_CMD);	// Send CMD55, required to precede all "application specific" commands
												// Do not check response here

SPI_set_speed(2);
	CS = SD_OFF;
	return 0;
	
}


[ Edited Sat Sep 06 2008, 01:33 am ]
Sat Sep 06 2008, 12:25 am
#15
How to send the serial Clock to the sd card?
Sat Sep 06 2008, 01:59 am
#16
most of your initialization routine is correct but few changes needed.

1. Make a routine for sending SPI byte
2. Make a routine for sending command to MMC

now see how to send command to MMC..

MMC command contains command byte + parameter bytes (hope you are taking care of it)
now after command is sent to mmc, you have to wait for response from mmc.
if you have a function to send SPI byte then..
response wait will be like this..

unsigned char MMCWait(){
int timeout = 1000;
unsigned char read;
while( (read == 0xff) && (timeout--) )
     read = spiSend(0xff);
return read;
}


so after you send command to MMC..
SD_WriteCommand(CMD0_GO_IDLE_STATE);
if(MMCWait() != 0x01) //response of Idle state
    return 0; //return failure status.. or whatever there in your program.


but when sending CMD1 to MMC, you have to do the way you have done already..

and please go through the documents i provided for MMC initialization. You only need to send CMD0 and CMD1 to mmc for full initialization.
no need to send CMD41 and CMD55.
Sat Sep 06 2008, 12:50 pm
#17
is a hexadecimal (like 0x55) considered as unsigned char?
Sat Sep 06 2008, 01:00 pm
#18
Does anyone know what does this error mean?

warning 110: conditional flow changed by optimizer: so said EVELYN the modified DOG
Sun Sep 07 2008, 10:55 pm
#19
l am trying to initialize SD card in SPI mode. what the difference between CMD1 and ACMD41? why don't need to send ACMD41 for SD card initialization?
Mon Sep 08 2008, 12:19 am
#20
well i have provided document for SD/MMC card initialization. Please check it I have worked on MMC myself so least thing required for this init is CMD0 and CMD1.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Lewisuhakeply
Thu Apr 18 2024, 06:00 pm
Darrellciz
Thu Apr 18 2024, 11:07 am
Charlessber
Thu Apr 18 2024, 09:29 am
BartonSem
Thu Apr 18 2024, 04:56 am
DonaldKnown
Thu Apr 18 2024, 12:24 am
utaletxcyw
Wed Apr 17 2024, 10:21 am
Anthonyvab
Wed Apr 17 2024, 08:48 am
RobertCix
Wed Apr 17 2024, 06:46 am