MD280/MD280N User Manual                              Appendix             
- 219 -
During generation of the CRC, each eight-bit character is exclusive 
ORed with the register contents. Then the result is shifted in the direction of 
the least significant bit (LSB), with a zero filled into the most significant bit 
(MSB) position.The LSB is extracted and examined.If the LSB was a 1, the 
register is then exclusive ORed with a preset, fixed value. If the LSB was a 
0, no exclusive OR takes place. This process is repeated until eight shifts 
have been performed. After the last (eighth) shift, the next eight-bit byte is 
exclusive ORed with the register's current value, and the process repeats 
for eight more shifts as described above. The final contents of the register, 
after all the bytes of the message have been applied, is the CRC value. 
 When the CRC is appended to the message, the low byte is appended 
first, followed by the high byte. 
 
unsigned int CrcValueCalc(const unsigned int *data, unsigned int length) 
{ 
    unsigned int crcValue = 0xffff; 
    int i; 
 
    while (length--) 
    { 
        crcValue ^= *data++; 
 
        for (i = 8 - 1; i >= 0; i--) 
        { 
            if (crcValue & 0x0001) 
            { 
                crcValue = (crcValue >> 1) ^ 0xa001; 
            } 
            else 
            { 
                crcValue = crcValue >> 1; 
            } 
        } 
    } 
 
    return (crcValue); 
} 
4
Communication Parameter Address
The chapter is about communication contents, it’s used to control the 
 
efesotomasyon.com