LPC1769 SD card SPI mode write performance issue

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

LPC1769 SD card SPI mode write performance issue

639 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wlamers on Fri Aug 31 07:26:31 MST 2012
Hello All,

I have a SD (or SDHC) card connected to a microcontroller via SPI mode. I am using Chan’s FAT library. I write data to it which comes from an 8192 byte buffer (buffer cannot be larger due to insufficient RAM). This writing is performed periodically. Normally writing is ready before the buffer is filled again. But once in a while (also depending on the buffer fill speed) things go wrong and writing is NOT ready before the new buffer has to be written, causing loss of data.

BTW, sector size is also set to 8192 bytes, but others do not seem to have an influence.

The writing can be monitored with a scope, and shows that sometimes writing takes a long time. E.g. 4x longer than usual.

Does someone knows what is going on here, and maybe how to prevent this from happening? Has this something to do with a read, modify, write sequence? Do I need an external RAM buffer? Or are there better ways to improve performance?

Thanks!
Labels (1)
0 Kudos
3 Replies

533 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wmues on Sat Sep 01 02:25:45 MST 2012
SLC SD cards may be better. But writing only 8K at a time is the source of the problem, because these 8K are less than an erase block size of the NAND flash inside the SD card. So the SD card controller must do some sort of housekeeping. A SD card is allowed to be busy for 250ms, but some cards are needing 1.5s.

IMHO, you are out of luck if you only have 8K RAM.
0 Kudos

533 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wlamers on Sat Sep 01 00:50:13 MST 2012
My apologies,  ofcourse I mean the cluster size.

Yes I use multi sector writes.

Someone pointed out that using aSLC SdCard could solve the issue. Has someone experience with this?
0 Kudos

533 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wmues on Fri Aug 31 13:04:49 MST 2012
The sector size is 512 Bytes. Always. So, what do you mean with sector size == 8192 Bytes? Do you mean cluster size?
Cluster size is not very important.

Do you use single sector writes or multi sector writes? Using multi sector writes will be a big advantage.

It is very common for SD cards to need time to do internal housekeeping if there is a big amount of data written. I have seen busy status for about 1.5 seconds. So you should have data buffers sufficient for this time.
0 Kudos