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:
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);
}