A CRC is generated through a calculation that’s done on the data and
then transmitted with the data. The receiver can do the same calculation
and then compare the CRCs. If the CRCs match, the data is most likely
good. Many communication schemes use CRC because it’s easy to implement
on the transmitting side and analyze on the receiving side.
this example, we’ll use the LMP90100 to show how the CRC is generated.
Data is sent out of the ADC on a serial bus in 24 bit pieces for each
conversion of the ADC. An 8-bit CRC can be sent with the data when the
LMP90100 is used in a noisy environment. The CRC transmission can also
be turned off when it is not needed.
A generator polynomial is used to calculate the CRC. This polynomial is
one bit longer than the resulting CRC. The LMP90100 uses a polynomial
of x8 + x5 + x4 + 1. It has a degree of
8, which means the polynomial has 9 terms and the CRC will have 8 bits.
Commonly used polynomials range from a degree of 1, (x + 1) which will
give you a parity bit, to a degree of 64. [USB uses a polynomial with a
degree of 5 (x5 + x2 + 1), Bluetooth uses a polynomial with a degree of 16 (x16 + x12 + x5 + 1), and Ethernet uses a 32 degree polynomial. ]
The polynomial can be represented in binary terms for the CRC
calculation by listing its coefficients. If this is done to the LMP90100
polynomial we get 100110001 (the coefficient of x8 is 1, the coefficient of x7 is 0, and so on). The CRC is generated using the following method.
data is left-shifted by the same amount of bits as the size of the CRC,
and 0s are added on the right side. For example, if the 24-bit ADC data
from the LMP90100 is 010101011000100101001011
and the CRC
from the LMP90100 is 8 bits, the data is shifted left 8 bits and 8
zeros are added on the right side. The data for the CRC calculation
would be: 01010101100010010100101100000000.
polynomial in binary form is put underneath the modified data. The MSB
of the polynomial is put under the left-most 1 of the data.
XOR (exclusive-OR) function is applied to the data and the polynomial.
The remaining data to the right of the polynomial is brought down. The
polynomial is once again put underneath the left-most 1 and the data is
again XORed. This continues until the left-most 1 of the remainder is in
the 8th or less bit position. Figure 1 shows the entire process for the
three bytes of data we are using.
Figure 1: Generation of a CRC
(click here to see enlarged image).
Once the CRC has been calculated, it can be sent with the conversion
data. The LMP90100, however, does not send the actual CRC, it sends the
one’s complement of the calculated CRC. This is done because if the data
is 0x000000, the CRC will be 0x00. The resulting data thatm is sent is
0x00000000 (three bytes of data and CRC).
This could be cause for concern (especially if this data set of all
zeros was repeatedly sent for a length of time) as perhaps something
happened to the data line, such as a short to ground. The one’s
complement of 0x00 is 0xFF, which means that the four bytes sent has
become 0x000000FF. This lets the microcontroller know that the data line
The ADC data in the LMP90100 is located in registers 0x1A, 0x1B and
0x1C. The CRC, in ones complement form, is located in register 0x1D.
This makes it easy for the microcontroller to read this data because it
starts at register 0x1A and simply reads a block of four bytes.
Once the microcontroller has the data and CRC, it can then do the same
calculation on the data. If the CRCs match the data, it’s most likely
good and can be used. If the CRCs do not match, the data can be
discarded and the microcontroller can ask for the data again, or just
wait for the next set of data.
When used in an industrial sensing application the integrity of the
data is critically important. The LMP90100 sensor AFE gives the designer
a proven method of checking that the microcontroller is receiving good
data by using a CRC. This approach ensures data integrity and a more
robust system, even when used in a noisy environment.
About the Author
is an applications manager for Texas Instruments Precision Systems
group, focused on precision signal chain products. Previously, Stout
worked as an applications engineer in National Semiconductor’s CRT and
Digital Television Products group. Stout received his Bachelor of
Science degree in Electrical Engineering from Brigham Young University.
Editor's note: Liked this? Want more?
If you are interested in "analog" issues
such as signal input/output (sensors and transducer, real-world I/O);
interfacing (level shifting, drivers/receivers); the signal chain;
signal processing (op amps, filters, ADCs and DACs); and signal
integrity, then go to the Planet Analog home page here for the latest in design, technology, trends, products, and news. Also, sign up for our weekly Planet Analog Newsletter here.