beautypg.com

Software procedures – Welch Allyn Duet CO2 Module - User Manual User Manual

Page 65

background image

Duet CO

2

Module OEM Implementation Manual

Welch Allyn OEM Technologies

Confidential

Page 65

Software Procedures

CRC Code Calculation

The 8 bit CRC code is based on the CCITT/CRC polynomial which uses the conventional right shifting
(high to low) method. The polynomial is:

G(x) = x^8 + x^7 + x^2 + 1

The feedback constant is 0xA1 (hex). CRC values are initialized to 0xFF (hex).

The CRC update value is implemented by a table look up scheme. The following is an
implementation example in ‘C’ language.

Usage:
#define updatecrc_8(value,crc) (crc_table_8[value^crc])
#define MAX_SIZE 23

/*choose any size*/

unsigned char crc_table_8[256];
unsigned char data[MAX_SIZE];

/*data to be CRC checked*/

unsigned char calc_crc(char data,int n)
{

unsigned char crc;
/*make_table_8( );*/

/*do this at least once*/

crc=0xFF;
for(i=0;i

crc=updatecrc_8(data[i],crc);

}
return(crc);

}