Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Example of how to generate CRC7 byte for SD cards in SPI mode
Latest commit b676c30 @hazelnusse Fixed some typos.
Failed to load latest commit information.
.gitignore Added a print function and a README
Makefile Initial commit. Fixed some typos. Added a print function and a README

When communicating to SD cards in SPI mode, a 6-byte command frame is used. The first byte is the command index. Bytes two through five are the argument. The last byte is a CRC byte that is calculated from the first five bytes. The CRC polynomial used in SD cards is:

G(x) = x^7 + x^3 + x^0

The result of CRC calculation goes in the upper 7 bits of the CRC byte. The 0 bit of is set high.

This code shows what the CRC7 bytes are for a few common SD commands.

You will need a gcc 4.7 or newer in order to build this with the current Makefile, although it should be straightforward to modify to work with earlier compilers or even with a C compiler.

Something went wrong with that request. Please try again.