
Working with Flash Memory 79
/**********************************************************************
*
* Function: crcCompute()
*
* Description: Compute the CRC checksum of a binary message block.
*
* Notes: This function expects that crcInit() has been called
* first to initialize the CRC lookup table.
*
* Returns: The CRC of the data.
*
**********************************************************************/
width
crcCompute(unsigned char * message, unsigned int nBytes)
{
unsigned int offset;
unsigned char byte;
width remainder = INITIAL_REMAINDER;
/*
* Divide the message by the polynomial, a byte at a time.
*/
for (offset = 0; offset < nBytes; offset++)
{
byte = (remainder >> (WIDTH - 8)) ^ message[offset];
remainder = crcTable[byte] ^ (remainder << 8);
}
/*
* The final remainder is the CRC result.
*/
return (remainder ^ FINAL_XOR_VALUE);
} /* crcCompute() */
Working with Flash Memory
From the programmer’s viewpoint, Flash is arguably the most complicated mem-
ory device ever invented. The hardware interface has improved somewhat since
the original devices were introduced in 1988, but there is still a long way to go.
Reading from Flash memory is fast and easy, as it should be. In fact, reading data
from a Flash is not all that different from reading from any other memory device.
*
The processor simply provides the address, and the memory device returns the
data stored at that location.