© 2000 Ubicom, Inc. All rights reserved. - 25 - www.ubicom.com SX IrDA Virtual Peripheral Implementation AN16 7.0 Appendix A - Frame Check Sequence (FCS) The FCS is a 16-bit CCITT CRC covering the payload data before transparency is applied (i.e. FCS must also be trans-
parent) as described on pages 113-116 of IrLAP.
•    The FCS is initialized to $FFFF.
•    For transmission the complement of the FCS is sent.
•    For reception the FCS of the data including the FCS bytes will result in $F0B8 for a valid frame.
7.0.1  Basic FCS Algorithm X = FCS-Low xor DATA FCS-Low = F(X)-Low xor FCS-High FCS-High = F(X)-High Table 7-1.  Virtual Table Algorithm F(X) X = X xor (X << 4) F(X)-High   = X xor (X >> 5) F(X)-Low = (F(X)-High >> 4) xor (X << 3) << N = Shift left N bits (does not wrap around) >> N = Shift right N bits (does not wrap around) 7.0.2  Final FCS Algorithm X = FCS-Low xor DATA X = X xor (X << 4) A = X xor (X >> 5) FCS-Low = (A >> 4) xor (X << 3) xor FCS-High FCS-High = A The FCS-Low variable is used to hold temporary variable X resulting in: FCS-Low = FCS-Low xor DATA FCS-Low = FCS-Low xor (FCS-Low << 4) A = FCS-Low  xor  (FCS-Low  >> 5) FCS-Low = (A >> 4) xor (FCS-Low << 3) xor FCS-High FCS-High = A Bit Algorithm 15 X7 xor X 3 14 X6 xor X 2 13 X5 xor X 1 12 X4 xor X 0 11 X3 10 X7 xor X 3 xor X2 9 X6 xor X 2 xor X1 8 X5 xor X 1 xor X0 7 X4 xor X 0 6 X3 5 X2 4 X1 3 X7 xor X3    xor  X0 2 X6 xor X2 1 X5 xor X1 0 X4 xor X0