Page 1 of 1

Addressing in an SD Standard capacity card

PostPosted: Mon Jan 04, 2016 11:02 pm
by Joseph Watson
I am about to write PIC18 assembly language code that accesses an SD card of standard capacity (that is, up to 2 gigabytes) using SPI. It is a version 2 card. The card is not formatted with a FAT system so I will be using RAW mode.

I have already dabbled with writing and reading a little data on this type of card but I want to expand on the theme and I am wanting everything to make sense before I plow into it all big time.

One of the commands available is the CMD17 command which reads the contents of a single 512-byte block. The CMD17 command includes a 32-bit field of information that specifies the start address for the block being read. Since this is a standard capacity card (not a High Capacity card), the address field is specified as a byte address, not a block address.

An unsigned 32-bit number can vary from 0 to 4,294,967,295. That is, it can address 4 billion addresses.

I rather expected that since standard capacity cards are limited to 2 gigabytes in capacity, the highest address that could be expressed in 32 bits would have been 2,147,483,647 but, as you can see, the address field can address twice that number of bytes. Is it true that the most significant bit of a CMD17 command's 32-bit address field is always zero or have I missed something in the specs? Are there portions of the address space where the card does not address the storage medium inside the card (implying that I would need to skip those portions)?

Re: Addressing in an SD Standard capacity card

PostPosted: Fri Jan 08, 2016 8:12 pm
by jtemples
I believe there are 4GB standard SD cards, but they do not comply with the spec. All 4GB and greater cards are supposed to be HC.

Re: Addressing in an SD Standard capacity card

PostPosted: Sat Jan 09, 2016 3:16 am
by Joseph Watson
jtemples,

I think you have introduced a good clue there. When I went looking for such a thing as a 4GB SD card that was not SDHC, I found this one for starters:

http://www.newegg.com/Product/Product.a ... 12K0EZ8257

So I guess the architecture of SDSC really can address 4 billion bytes. They just normally don't because the standard says that they should not.

Thanks

Re: Addressing in an SD Standard capacity card

PostPosted: Sat Jan 09, 2016 3:02 pm
by jtemples
Yes, that's the kind of card I was remembering. I don't believe those kinds of cards do anything special or unusual, they just don't comply with the spec. In fact, the Sandisk spec specifically points out that the maximum size that can be encoded in the CSD register is 4 GB. I don't think it was until the HC spec was released that a 4GB standard card was considered out of spec.

Re: Addressing in an SD Standard capacity card

PostPosted: Tue Jan 12, 2016 1:05 am
by ric
It's probably to avoid those pesky negative numbers you get when you go over 2GB, and have been too lazy to declare your variables as unsigned. ;)