SD card write and read issues

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SD card write and read issues

1,556 Views
prachipanse
Contributor III

Hi,

I have modified the SD card example project (AN10916) for FAT32 file system that was available for LPC1700 controller. I am using the LPC1313 controller. I am seeing the below issues:

1. I am able to initialize the SD card properly and read the configuration.

However, if I try to read using the SD_ReadSector() function, after reading the configuration, then it fails most of the times. The card doesn't indicate that it is ready (DI signal is High)  using the SD_WaitForReady() function.

However, if I read from the card without reading the configuration first, then the read seems to pass properly.

2. The write function SD_WriteSector() always indicates a failure. However, when I try to read from the sector to which I have tried to write, I see that the data is being written. 

Please let me know what may be the issue.

Thanks and Regards,

Prachi

Labels (3)
Tags (4)
0 Kudos
Reply
4 Replies

1,145 Views
Dezheng_Tang
NXP Employee
NXP Employee

Neither LPC176x nor LPC1313 has the true SD interface but uses SSP and 1-bit mode for SD card access, so CPU speed and SSP clock setting is important. LPC13xx is slower than LPC17xx, you need to adjust the SSP and CPU clock

accordingly. Make sure SD_ReadConfiguration works all the time first with the card you are testing, if you can't read CID and CSD info of the card, therre is no need to try SD_ReadSector/SD_WriteSector.

Make sure your CPU speed is maximum and two phases of the SSP clock are no more than 400KHz and 25MHz respectively, then try to lower the SSP clock gradually see if you can read/write the card or not.

0 Kudos
Reply

1,145 Views
prachipanse
Contributor III

Hi,

Thank you for your response. When I run the SD_ReadConfiguration() function in a loop after a successful SD_initialization, the function seems to pass alternately. If do not execute the SD_STATUS (command 13), then the function passes successfully each time.

In the SD_SendCommand() function, once the 6 byte command is send, then the response from the SD card is checked. It says, "The command response time (Ncr) is 0 to 8 bytes for SDC, 1 to 8 bytes for MMC." Is this as per the SD standard? I seem to be able to receive the command in 0 to 10 bytes. Also, I get the response after the introduction of some delay after the command is send.

What may be the issue in this case? 

Regards,

Prachi

0 Kudos
Reply

1,145 Views
prachipanse
Contributor III

I want to add another point. The SD_STATUS register is always read as 0 when I read the configuration.

Regards,

Prachi

0 Kudos
Reply

1,145 Views
prachipanse
Contributor III

Hi,

I found out the above issues were seen because the timer value was not accurately set. With that correction, the issue is resolved using NCR value of 8 itself.

Thanks. 

0 Kudos
Reply