This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F280025C-Q1: How to set the CRC setting

Part Number: TMS320F280025C-Q1
Other Parts Discussed in Thread: C2000WARE

Tool/software:

Hi team,

Because of the function safety requirement, customer will use the web CRC tools to calculate the CRC data, and then compare it with the result that get from the DSP CRC calculation element.

And they configurate it in syscfg, it have a lot of setting and we try a lot of different configurations and a lot of times.

But the result is always different from the result that get from the web CRC tools: CRC在线计算

Could you help to configurate the CRC setting in syscfg based on this web CRC tools?

BRs

Shuqing

  • Hi Shuqing,

     

    Here’s an e2e that I believe will help

    https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1275572/tms320f280039c-vcrc-configuration-to-match-standard-crc-32-algorithm/4834892#4834892

     

    Specifically:

    1. I noticed that both inputs and outputs are bit reversed (both are checked in the Chinese language pic you included in the e2e). Therefore, the polynomial to use is not CRC_run32BitPoly1 but CRC_run32BitPoly1Reflected, and additionally
    2. Seed value in syscfg needs to be set to 0xFFFFFFFF , not 0x0 (based on the setting in the Chinese language pic you included in the e2e)
    3. Since the output is XORd (based on the setting in the Chinese language pic you included in the e2e), you need the post-process the output CRC like this i.e. bit reverse

    myVRCR0_Handle->run(myVRCR0_Handle);

    crcResult = myVRCR0_Handle ->crcResult;

    crcResult = __flip32(crcResult);

           crcResult = ~crcResult;

    1. Finally, and this is specific to the way the library does the computation. It processes the LSB first, then the MSB, so in your testData (0x3700, 0x1234, ..) if you want the processing order for CRC computation to be 0x37, then 0x00, then 0x12, then 0x34, … they should be provided as (0x0037, 0x3412, …)

     

    Thanks,

    Sira

  • Hi Sira,

    It still not work when I change to this:

    And still some question:

    1.

    Finally, and this is specific to the way the library does the computation. It processes the LSB first, then the MSB, so in your testData (0x3700, 0x1234, ..) if you want the processing order for CRC computation to be 0x37, then 0x00, then 0x12, then 0x34, … they should be provided as (0x0037, 0x3412, …)

    I think it can be resolved by changing below setting? Not need to change the input data?

    2. 

    I noticed that both inputs and outputs are bit reversed (both are checked in the Chinese language pic you included in the e2e). Therefore, the polynomial to use is not CRC_run32BitPoly1 but CRC_run32BitPoly1Reflected, and additionally

    This can be resolved by set this?

    3. What's the difference between CRC_run32BitPoly1Reflected and the function in syscfg?

    BRs

    Shuqing

  • Shuqing,

    Your updated testInput is still wrong. Remember that the C28 does not support an 8-bit byte. Therefore your updated input buffer will process data as 0x00 0x00 0x37 0x00  0x34 0x00...so it won't work.

    Changing the parity setting will not work, because that only tells the library whether to start the computation from the LSB or the MSB for the 1st word. After that it will always use LSB - MSB. 

    So for even parity it will be (LSB-MSB)-(LSB-MSB)-(LSB-MSB), and for odd parity, it will be (MSB)-(LSB-MSB)-(LSB-MSB)-(LSB-MSB)-..

    I am not sure about the HW CRC functions - you could try and see what code they generate. But idea is to use CRC_run32BitPoly1Reflected  as well as the post-processing code I sent.

  • So I need to define like this? not unit16 but uint8

    In addition to that,

    _flip32() can't be find althogh I add the library into project

    BRs

    Shuqing

  • Shuqing,

    No, you should use uint16_t and flip the bytes.

    Instead of 0x3700, 0x1234, 

    use

    0x0037, 0x3412, ..

    It's __flip32 not _flip32

  • HI Sira,

    thanks for your help. Now I get the correct result.

    But customer want to use syscfg, that means if it need to add the below code in their project, it will be not a good way

    Could we achieve it use the hardware CRC computation?

  • Shuqing,

    Good to hear!

    Can you give me one additional detail - with each of the Hardware CRC function choices, what is the .run function that is generated? Is it the same function as the selected function?

    Thanks,

    Sira

  • Hi Sira

    Customer don’t care which hardware CRC choose, they just want to use syscfg to generate the same result as the web https://www.lddgo.net/encrypt/crc

    Could you give a corresponds configuration?

    BRs

    Shuqing

  • Hi Shuqing,

    Unfortauntely, choosing VCU2 functions as an option are not enabled in the current C2000 syscfg module. So the second best thing is to initalize and setup CRC structs in sycfg but change the run function during the main initalization routine like you showed above. Not ideal but it won't cause any harms to the program.

    We're looking into this CRC module and have started an internal discussion on bring in VCU2 functionalities into the module. My hope is that we can have CRC module update by the next C2000Ware release.

    Best,

    Sen Wang