12.07.2015 Views

3GPP TS

3GPP TS

3GPP TS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Release 199850<strong>3GPP</strong> <strong>TS</strong> 07.10 V7.2.0 (2002-03)B.3 ImplementationImplementation is very simple because the FCS will be as wide as the lookup table (8 bits). To avoid having to reverseall bits in the octets all the octets in the crc table is reversed instead.7 6 5 4 3 2 1 k(1)The term ( x + x + x + x + x + x + x + xR) corresponds to initialising the FCS with 0xFF.8 2x + x + x1 + 1B.3.1Calculate FCS for the example given earlierFirst initiliaze the crc:FCS=0xFFAdd first byte:FCS=table[0xFF^0x07]=table[0xF8]=0xBAAdd second byte:FCS=table[0xBA^0x3F]=table[0x85]=0x76Ones complement the FCS: FCS=0xFF-FCS=0xFF-0x76=0x89 (10001001)Transmit this FCS, this will be the same as the one calculated previous after the uart has reversed the bits.B.3.2Check FCS for the example given earlierFirst initiliaze the crc:FCS=0xFFAdd first byte:FCS=table[0xFF^0x07]=table[0xF8]=0xBAAdd second byte:FCS=table[0xBA^0x3F]=table[0x85]=0x76Add FCS:FCS=table[0x76^0x89]=table[0xFF]=0xCF0xCF is the reversed order of 11110011, the checksum is validB.3.3The transmitter code/*Init*/unsigned char FCS=0xFF;unsigned char len;unsigned char p;/*len is the number of bytes in the message, p points to message*/while (len--) {FCS=crctable[FCS^*p++];}/*Ones complement*/FCS=0xFF-FCS;B.3.4The receiver code/*Init*/unsigned char FCS=0xFF;unsigned char len;unsigned char p;/*len is the number of bytes in the message, p points to message*/while (len--) {FCS=crctable[FCS^*p++];}/*Ones complement*/FCS=crctable[FCS^"received FCS"];/*0xCF is the reversed order of 11110011.*/if (FCS==0xCF) {/*FCS is OK*/}else {/*FCS is not OK*/}<strong>3GPP</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!