Please tell me : flexray header crc calcultion of mathod.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Please tell me : flexray header crc calcultion of mathod.

3,217 Views
charlie_kim
Contributor I

Hi. I'm charlie.

 

I study flexray. I want header crc calcultion of mathod.

 

I had example code.

  ▶ sync frame indicator : 1

  ▶ startup frame indicator ; 1

  ▶ frame Id : 1 (11bit : 000 0000 0001)

  ▶ payload lenth : 16(7bit : 001 0000)

  ▶ CRC polynomial : X^11+X^9+X^8+X^7+X^2+1

 

  ---> result  CRC code :  242

 

but, I didn't have result. 

attachment file my calcultion. please tell me,  I make an error in calculation.

 

-> sync / start / frame id / lenth / plus bit(10ea)

             11 0000 0000 0010 0100 0000 0000 0000

-> ploynomial

             1011 1000 0101

--> my result : 0x3cc(972)

 

 

best regard

 

Labels (1)
0 Kudos
2 Replies

1,121 Views
Flo_C
Contributor I

Hi,

 

have you got found an answer about your subject???

I have the same problem.

 

Best regards

Florent

0 Kudos

1,121 Views
admin
Specialist II

Chapter 4.5 of FlexRay Protocol Specification will help you.

4.5 CRC calculation detailsThe behavior of the CODEC while processing a received frame depends on whether or not the receivedheader and frame CRCs are verified to match the values locally calculated using the actual frame data (seeFigure 3-29 and Figure 3-34). The CODEC also appends the CRC in the trailer segment of a transmittedframe (see section 3.2.1.1.6). The algorithm executed to calculate the CRC is the same in all cases exceptfor the initial values of several algorithm parameters (see below).4.5.1 CRC calculation algorithmInitialize the CRC shift register with the appropriate initialization value. As long as bits (vNextBit) from theheader or payload segment of the frame are available the while-loop is executed. The number of bitsavailable in the payload segment is derived from the payload length field. The bits54 of the header andpayload segments are fed into the CRC register by using the variable vNextBit, bit by bit, in network order,e.g., for the FlexRay frame CRC calculation the first bit used as vNextBit is the reserved bit field, and thelast bit used is the least significant bit of the last byte of the payload segment.The following pseudo code summarizes the CRC calculation algorithm:vCrcReg(vCrcSize - 1 : 0) = vCrcInit; // Initialize the CRC registerwhile(vNextBit)// determine if the CRC polynomial has to be applied by taking// the exclusive OR of the most significant bit of the CRC register// and the next bit to be fed into the registervCrcNext = vNextBit EXOR vCrcReg(vCrcSize - 1);// Shift the CRC register left by one bitvCrcReg (vCrcSize - 1 : 1) = vCrcReg(vCrcSize - 2 : 0);vCrcReg(0) = 0;// Apply the CRC polynomial if necessaryif vCrcNextvCrcReg(vCrcSize - 1 : 0) =vCrcReg(vCrcSize - 1 : 0) EXOR vCrcPolynomial;end; // end ifend; // end while loop4.5.2 Header CRC calculationAmong its other uses, the header CRC field of a FlexRay frame is intended to provide protection againstimproper modification of the sync frame indicator or startup frame indicator fields by a faulty communicationcontroller (CC). The CC that is responsible for transmitting a particular frame shall not compute the headerCRC field for that frame. Rather, the CC shall be configured with the appropriate header CRC for a givenframe by the host55.When a CC receives a frame it shall perform the header CRC computations based on the header fieldvalues received and check the computed value against the header CRC value received in the frame. Theframes from each channel are processed independently. The algorithm described in section 4.5.1 is usedto calculate the header CRC. The parameters for the algorithm are defined as follows:FlexRay header CRC calculation algorithm parameters:vCrcSize = cHCrcSize; // (= 11) size of the register is 11 bitsvCrcInit = cHCrcInit; // (= 0x1A) initialization vector of header// CRC for both channelsvCrcPolynomial = cHCrcPolynomial; // (= 0x385) hexadecimal representation of// the header CRC polynomialThe results of the calculation (vCrcReg) are compared to the header CRC value in the frame. If thecalculated and received values match the header CRC check passes, otherwise it fails.

 Just keep in mind header bit orientation - LSB is SY bit, next - SU, next - MSB of FID etc.

0 Kudos