beautypg.com

Welch Allyn Duet CO2 Module - User Manual User Manual

Page 66

background image

Duet CO

2

Module OEM Implementation Manual

Page 66

Confidential

Welch Allyn OEM Technologies

The table can be created by the following code:

void make_table_8(void)
{

const unsigned char feedback_8=0xA1;
unsigned char crc;
unsigned int i;
unsigned char j, tmp;
for (i =0; i < 256; i++) {

tmp = i;
crc = 0;
for (j = 0; j< 8; j++) {

if (( tmp & 1) ^ (crc & 1))

crc = (crc >> 1) ^ feedback_8;

else

crc >>= 1;

tmp >>= 1;

}
crc_table_8[i] = crc;

}

}

CRC Example:

Using the following Waveform Byte String as an example:

CO

2

= 37.50 mmHg

{STX}

“W”

xx

yy

CCITT/CRC

{ETX}

waveform byte string

0x25

0x80

0x79

{STX}W258079{ETX}

02h 057h 0x25 0x80 0x79 03h

with the actual byte stream as:

"{STX}W258079{ETX}"

In our example, 057h represents a single character, the ASCII letter "W". 0x25 represents the
resulting value of the ASCII HEX representation of the parameter value. Thus 0x25 is actually
transmitted as 32h (ASCII letter "2") followed by 35h (ASCII letter "5").

The CRC check should be performed at a very low level within the host's software. A CRC of the
actual transmitted bytes excluding the check byte (which is sent as 2 ASCII HEX characters)
should be performed by the host on the 8 bit binary numbers retrieved from the Asynchronous
UART starting with the character immediately following the {STX} and ending with the character
immediately preceding the two ASCII HEX check characters.

The CRC is initially seeded with 0xFF before the CRC is computed. This is a very common
practice.