unsigned short crc16(Uint32*, Uint16); // Global variables unsigned short CRC; Uint32 Flash = 0x3F7FFF; Uint32 *FlashAddr; main() { FlashAddr = &Flash; CRC = crc16(FlashAddr, 0x3FFD); Fail(); // Just so I stop after the calculation. } unsigned short crc16(Uint32 *buf, Uint16 len ) { unsigned short crc = 0; while( len-- ) { int i; BitData.MOT_SPD = *(Uint16 *)buf; crc ^= *(Uint16 *)buf++ << 8; for( i = 0; i < 8; ++i ) { if( crc & 0x8000 ) crc = (crc << 1) ^ 0x1021; else crc = crc << 1; } } return crc; }