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.

SD card long random write delays in SPI mode

Status
Not open for further replies.

am85

Member level 2
Joined
May 30, 2011
Messages
46
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Germany
Activity points
1,661
Hi,

I am using a 32 GB 400x SDHC card. I am writing to the SD card using SPI mode at 50 MHz. I use a Buffer to store the data first and then write to the card. 512 Bytes from the buffer are ready for the SD card every 100 us. Normally, it takes around 88 us to write one sector on the SD card. However, sometimes there is a very long write delay (10-50 ms) between sectors. Afterwards, it goes back to the usual 88 us/sector. It is totally random, so sometimes it happens and sometimes not, and with no fixed delay time. I have a 300-sector buffer, but it is still not enough. It seems the delay happens more than once successively causing delays longer than the buffer can handle.

Any ideas why this happens or how to fix it ?

Thanks.
 

Are you writing through a file system or logical sectors directly? Is the SDCard (mostly) erased before writing data?

Generally, the delay is most likely caused by internal housekeeping actions of the flash translation layer. It requires that from time to time physical blocks have to be erased and copied. Consider that the smallest write entity is a page of e.g. 1kB size and an erase entity (block) has e.g. 2 MB size with large capacity NAND flash.

At least for multiple sector writes, the timing can be improved by performing ACMD 23 pre-erase actions, refer to the SDCard specification. I'm not sure if it helps for single sector writes.
 

Thanks for your reply. Firstly, I format the SD card using windows format option, then copy and paste a 2 GB empty file to the card. Then , I write continuously(not single blocks) directly to the sectors starting by the address where the file begins.

From what I read, this command is done once before starting the continuous write command. Does this mean I need to erase the whole card in the beginning, or every certain number of blocks I should stop the continuous write, erase, then continue writing again ?
 

I am trying now to perform a pre-erase CMD before writing. I am trying ACMD23 and also CMD32,33 and 38. It is not working yet. I am also trying CMD6 for high speed mode but also not working.Does it work with SPI mode? I would appreciate any help on how to issue these commands and the sequence.

Thanks a lot.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top