Using SD cards with large block lengths with LPC2148

Hi. I am not sure if this is the correct place to post this, but it kinda relates to the LPC2148.

Sorry if this is common knowledge or something, but I can’t seem to find good information on this anywhere. I am attempting to use a [LPC2148 demo code, specifically, I am trying to use the [FatFS code to get the controller to talk to a memory card. It does work for some cards, but not for others. I believe the reason stems from some cards having a non-standard block size. I have one card (2GB not SDHC) which reports a block size of 1024. The read function fails when attempting to read anything from this card, and near as I can tell, the card stops responding after the first read (I get one 512 byte chunk of good data and then nothing but 1s).

Reading the [SD Card Specs I came across two interesting tidbits on page 96:

In case of Standard Capacity Card, the size in the data token is determined by the block length set by SET_BLOCKLEN (CMD16).

The maximum block length is given by 512 Bytes regardless of READ_BL_LEN, defined in the CSD.

I use CMD16 to set the block length to the maximum value in the CSD (1024) during the card initialization routine. From what I understand, that should make the read command return that number of bytes. However, it seems like from the second quote, that I am not allowed to do this. Has anyone else run into this problem? and if so, what is the proper solution.

I will probably try to set a smaller block size with CMD16 and see what happens, but I am running out of ideas.](http://www.sdcard.org/developers/tech/sdcard/pls/)](FatFs - Generic FAT Filesystem Module)](LPC2148 Demo Code Overview)

No SD card experts here, I guess. :frowning:

For future reference: I tried setting the block length to 512 using CMD16, and telling the program to ignore the larger block size, and it seems to be working. I have not had too much time to test it, but I can read files off the card (or at least, the names of the files).

FAT assumes 512-byte sectors. Set the block length to 512. If the card can’t handle that I’d toss it in the bin.

Edit: I should have said most FAT implementations.

Right. The problem came from the initialization code setting the block size to the maximum allowable, which for some cards is more than 512 (it was 1024 in my case). I added a check that limited the block size to 512 and all seems to be well. I can write ~3000 conversions from the A/D to the card per second. :slight_smile:

Now to try and get the Ethernet working…