
69
For example, read 2 characters from the address which is at 2102H address of 01H inverter, the last content
calculation of CRC Cache memory from ADR to the last character of number of data calculate is F76FH, then
command signal is shown as follows, among which 6FH is sending before F7H:
Commands
ADR
01H
CMD
03H
Initial data address
21H
02H
Data
(calculated
by
word)
00H
02H
CRC CHK Low
6FH
CRC CHK High
F7H
Example:
CRC value below is generated from C++. And this function shall be assisted with two parameters:
Unsigned char* data ← // Data reference index
Unsigned char length ← // Length of data reference index
The function returns the CRC value as a type of unsigned integer.
unsigned int crc_chk ( unsigned char* data, unsigned char length){
int j;
unsigned int reg_crc=0Xffff;
while ( length--){
reg_crc ^=*data++;
for(j=0; j<8; j++){
if (reg_crc & 0x01) {/*LSB(b0)=1 */
reg_crc=(reg_crc>>1) ^ 0XA001;
} else {
reg_crc=reg_crc>>1;
}
}
}
return reg_crc; // Final value fit with CRC Cache memory
}