Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

Problem in initialization of SDHC card

Status
Not open for further replies.

w_bwr

Member level 3
Joined
Feb 4, 2010
Messages
66
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Karachi, Pakistan
Activity points
1,810
My code works fine SD card < 2GB. but when i use SDHC (>2GB) , it gives error in initialization.

Here is the code:

Code:
static WORD spiSD_Init(WORD j)
{
WORD aFreq= SPISD_BRATE_PINDEFAULT;
BYTE i, Y= 0xFF; 

SetBit(SPI_CS_PORT, SPI_CS_PIN);                                                                   // SPI CS pin: inactive
ClrBit(SPI_CS_ODP, SPI_CS_PIN);                                                                    //           : push/pull mode
SetBit(SPI_CS_DP, SPI_CS_PIN);                                                                     //           : output

SetBit(SPI_DATAOUT_PORT, SPI_DATAOUT_PIN);                                                         // SPI MTSR: 1
ClrBit(SPI_DATAOUT_ODP, SPI_DATAOUT_PIN);                                                          //         : push/pull mode
SetBit(SPI_DATAOUT_DP, SPI_DATAOUT_PIN);                                                           //         : output

SetBit(SPI_CLK_PORT, SPI_CLK_PIN);                                                                 // SPI SCLK: 1
ClrBit(SPI_CLK_ODP, SPI_CLK_PIN);                                                                  //         : push/pull mode
SetBit(SPI_CLK_DP, SPI_CLK_PIN);                                                                   //         : output

SetBit(SPI_DATAIN_PORT, SPI_DATAIN_PIN);                                                           // SPI MRST: 1
SetBit(SPI_DATAIN_ODP, SPI_DATAIN_PIN);                                                            // 1: open drain, does not matter
ClrBit(SPI_DATAIN_DP, SPI_DATAIN_PIN);                                                             //         : input

_nop();

// make sure to have '1' at the line
for ( i= 0; i< 10; i++ )
    spiSD_Write((BYTE *)&Y, 1); 


return(j);
}
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
47,494
Helped
14,051
Reputation
28,357
Reaction score
12,709
Trophy points
1,393
Location
Bochum, Germany
Activity points
276,187
There's no change in initial reset for high capacity SD cards (SDHC). The differences are in succeeding command sequence.

 

w_bwr

Member level 3
Joined
Feb 4, 2010
Messages
66
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Karachi, Pakistan
Activity points
1,810
There's no change in initial reset for high capacity SD cards (SDHC). The differences are in succeeding command sequence.
Yup, I have gone through the this before.
My Init() routine doesn't send any commands, but only some pulses.
I modified it to this:


Code:
static WORD spiSD_Init(WORD j)
{
WORD aFreq= SPISD_BRATE_PINDEFAULT;
BYTE i, Y= 0xFF;
BYTE idle[6] = {0x40,0x00,0x00,0x00,0x00,0x95};
unsigned int retry;


SetBit(SPI_CS_PORT, SPI_CS_PIN);                                                                   // SPI CS pin: inactive
ClrBit(SPI_CS_ODP, SPI_CS_PIN);                                                                    //           : push/pull mode
SetBit(SPI_CS_DP, SPI_CS_PIN);                                                                     //           : output

SetBit(SPI_DATAOUT_PORT, SPI_DATAOUT_PIN);                                                         // SPI MTSR: 1
ClrBit(SPI_DATAOUT_ODP, SPI_DATAOUT_PIN);                                                          //         : push/pull mode
SetBit(SPI_DATAOUT_DP, SPI_DATAOUT_PIN);                                                           //         : output

SetBit(SPI_CLK_PORT, SPI_CLK_PIN);                                                                 // SPI SCLK: 1
ClrBit(SPI_CLK_ODP, SPI_CLK_PIN);                                                                  //         : push/pull mode
SetBit(SPI_CLK_DP, SPI_CLK_PIN);                                                                   //         : output

SetBit(SPI_DATAIN_PORT, SPI_DATAIN_PIN);                                                           // SPI MRST: 1
SetBit(SPI_DATAIN_ODP, SPI_DATAIN_PIN);                                                            // 1: open drain, does not matter
ClrBit(SPI_DATAIN_DP, SPI_DATAIN_PIN);                                                             //         : input

_nop();

// make sure to have '1' at the line
for ( i= 0; i< 10; i++ )
    spiSD_Write((BYTE *)&Y, 1); 
//sprintf(cTextOutput, "Ver: %s Build: %s %s\r\n", FirmwareVersion, __DATE__, __TIME__);
//LowLevelDebug_SerialPrintStr(cTextOutput, strlen(cTextOutput));
do
	{
	spiSD_Write(idle,6);
	SPI_DELAY();
	spiSD_Read(&response,1);
	if(retry++ > 150) break;
	}while(response != 0x01);
if (response != 0x01)
	{
	sprintf(cTextOutput, "IDLE State Error : %d\n\r",response);
	LowLevelDebug_SerialPrintStr(cTextOutput,strlen(cTextOutput));
	}
else
	{ 
	sprintf(cTextOutput," IDLE State Successful");
	LowLevelDebug_SerialPrintStr(cTextOutput,strlen(cTextOutput));
	}
return(j);
}
It should return 0x01 but it returns 0xFF but still my 256 MB card works but 4 GB doesn't.
 

sumith

Newbie level 3
Joined
Jan 12, 2013
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,292
Hi,

I have the same problem. The SDHC card response is 0xff ,and not 0x01. I am using microchip application library v1.4.2 . The SPI working fine.

Could anyone solve this?
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
47,494
Helped
14,051
Reputation
28,357
Reaction score
12,709
Trophy points
1,393
Location
Bochum, Germany
Activity points
276,187
I am using microchip application library v1.4.2
I presume, you are talking about MDD v1.4.2, there's no MHCP application library version number.

MDD is generally working fine with SDHC. To analyze your problem in details, you would want to mention the actual hardware target. I also think that MCHP forum is the appropriate place to discuss the problem, at least there's a good chance to meet people using MDD with the same processor target.

As another point, SDHC failure isn't necessarily a software problem. SDHC controllers are often using faster chip technology than standard cards and thus more sensitive to signal integrity issues, e.g. ringing SPI clock.
 
  • Like
Reactions: sumith

    sumith

    points: 2
    Helpful Answer Positive Rating

sumith

Newbie level 3
Joined
Jan 12, 2013
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,292
Hi,

I am using PIC24fj128ga010 micro controller. I have a pick tail board with me. The circuit actually used for sd card which works fine. I used transcend 4 gb sdhc card.I just want to create a file in sd card.

I hope you can help me. I posted the issue in mchp forum and expecting reply.

Thank you
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
47,494
Helped
14,051
Reputation
28,357
Reaction score
12,709
Trophy points
1,393
Location
Bochum, Germany
Activity points
276,187
I am using PIC24fj128ga010 micro controller. I have a pick tail board with me.
Means you are using DM240001 Explorer16 board with AC164122 SD PICtail?
 

sumith

Newbie level 3
Joined
Jan 12, 2013
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,292
Means you are using DM240001 Explorer16 board with AC164122 SD PICtail?

Hi,

Yes,you are right. I am still working on it.

Thank you.
 

sudhakar a

Junior Member level 3
Joined
Jun 3, 2013
Messages
30
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,503
Hi FvM,

I have the same problem. The 4gb SDHC card response is 0xff ,and not 0x01. I am using m16c microcontroller . The SPI working fine.But now I am follow the your flow chart 4gb SDHC card response is 0x01,but in getbootsector data function the mbr signature value is not matched.

Could you solve this?

Thanks in advanced
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
47,494
Helped
14,051
Reputation
28,357
Reaction score
12,709
Trophy points
1,393
Location
Bochum, Germany
Activity points
276,187
There are many known working SD card libraries supporting SDHC, e.g. FATFS being the most popular. I'm sure you can solve the problem by either importing the libraries or reviewing the code.

I see that one point related to SDHC hasn't been mentioned in this thread. Besides different initialization sequence, there's a different addressing scheme in read/write commands. The address is counting blocks instead of bytes.
 

sudhakar a

Junior Member level 3
Joined
Jun 3, 2013
Messages
30
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,503
Hi Fvm,
thanks for replying me.small doubt what is the need of CMD8 command.i could not apply this command in my code that's why I got the error message in get bootsector data function.Mean the value not equal to trailing signature(0xAA55).this is wrong or right?explain please
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top