Has anyone written the CRC generation routine for the CRC-7 error checking for MMC cards ?

The poly is X^7 + X^3 + 1 or (0x89). CRC initial value = 0x00.

According to the SanDisk documentation, this is a valid reset command:

0x40, 0x00, 0x00, 0x00, 0x00, 0x95

The 0x95 is actually a left justified CRC value of 0x4A with 1 added for the stop bit. ((0x4A << 1) + 1) = 0x95

However, I haven't been able to duplicate this value. Here is the method.

7..0

C <-- CRC <-- 0x40,0x00,0x00,0x00,0x00,0x00 (40 data + 7 pad bits)

| ^

| |

| xor

| |

+---> poly

Any help would be appreciated.

Thanks,

Fiz