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.

TMS320F280039C: CRC 32 C calculation problem in the library

Part Number: TMS320F280039C
Other Parts Discussed in Thread: C2000WARE

hello 
regarding that thread TMS320F280039C: TMS320F280039C - C2000 microcontrollers forum - C2000Tm︎ microcontrollers - TI E2E support forums
i got an advice from a Ti consultant about my problem but i can't implement his solution
Mr Sira proposed that i should use getCRC32_vcu_hilo_order_swap function that was added in Cware2000 latest version 5. 
i downloaded it and don't know how to integrate it in the VCRC library 
Here is the problem i want to use CRC32 C  calculations an as in the picture it show what kind of steps to calculate CRC32C and it difference from the MPGE_2

the inputs for the function doesn't specify the lookup table which is different from MPGE_2 and, i don't think that the lookup table 0x1edc6f41 which is used for CRC32 C calculation is supported in the VCU0 library


also in the example given for the new function 

i use the VCRC and use that configuration for CRC32C i have to flip the bytes in order to get the right value but i can't do it with bigger data as it will cause stack and memory related errors, can you please give me the steps on how to use the upgraded library in Cware2000 version 5 for my problem ? 

the question is how the update will help me avoid flipping the data ? and how to integrate it, i used the code in the vcrc_configpoly example to to do CRC32_C calculations 

thanks 

  • Mahmoud

    See attached picture below, which describes the sequence of operations to compute a CRC32 vs CRC32-MPEG2.

    For CRC32, you will use the flipInputBuf_cpu(), followed by getCRC32_vcu(), followed by __flip32() and finally logical NOT to get the result.

    Yes, CRC0 does not support the CRC32 polynomial, so this method is applicable to VCU2 and the VCRC (F28003x).

    Thanks,

    Sira

  • thanks for your response 
    will the flipInputBuf_cpu() function cause stack overflow problem if it has to flip a very large data "the app data sent to bootloader" because i already implemented code that flips the array elements and caused a problem for large data 

  • Mahmoud,

    If the buffer to be flipped is very large, then the flipping and CRC operations may need to broken down into smaller chunks and called in a loop.

    But the bigger question is - if you're using F28003x, it has the VCRC, which has HW support to flip data before computing the CRC. So the external flipping operation is not needed.

    See below from the VCRC chapter of spruhs1

    Thanks,

    Sira

  • Sira,
    well first i looked for the registers of the VCU during debugging but there don't show values, it says "Error Unable to read" 

    second i searched the Cware folder for that register you mentioned CRCMSGFLIP and found some assembly files, i don't know how to integrate that assembly code in my project ? the file name is vcrc_configpoly_asm 

    i just put the file on my project directory and called the _CRC_runConfigPolyBytesReflected: but it had no effect ? 

    what should i include so that the assembly file will work on my project ? 

    one more question 
    i don't understand the difference between 
    VCRC, VCU0, VCU2 for my code i used the VCRC library, could you tell me what is the difference bewteen those libraries ? 

    thanks 

  • Mahmoud,

    VCU0, VCU2, VCRC are Hardware IPs on chip. VCU0 came first (with CRC, FFT, etc. capabilities), VCU2 came next (with some enhancements e.g. support for 2 CRC polynomials, flipping prior to compute, etc.). Then came VCRC (with support removed for everything other than CRC, but added CRC configuration capability - like variable length, configurable polynomial etc.

    Please refer to the 28003x_vcrc_crc_32 example in C2000Ware, which has a call to the CRC_run32BitPoly2Reflected function of the library. Also look at the definition of this function in the VCRC library (c28x_vcrc_library) in vcu2_crc_32.asm.

    The register display issue I'm not so sure about - I'll have to check it.

    Thanks,

    Sira

  • thanks but i ran into a second problem which is the limited length the CRC function can take to calculate the CRC, i want to calculate the CRC on a very big chunk of memory  98 K bytes, when calculated it give me a wronf answer after the length of 32 K bytes maybe there is a limit on that function here 


    so my proposed solution would be to make the calculations on chunks "if that is true and the function and the CRC hardware has some limitations" then i want to know please how to do it ? let's say i calculated the first 32 k byte i got a value crc for first 32 k byte  how to use that value with the second chunk of memory which parameter to used i know i will add a second input to the function for that  but how to use the previous CRC value for the next chunk to calculate the whole 98 k bytes 

    thanks 

  • i also tried the CRC_run32BitPoly2Reflected  but it didn't work, it returned a value that is not on the online calculator 
    if the input to the function is 0x0096  "the value to be calculated by CRC " then what should i type in the online calculator ? 

  • Please give me a day or two to look into these details.

  • okay, thanks i will be waiting for your response 
    just to confirm about the length limit, i tested it in my code then i read it in one of the header files vcu2_crc,h there is a limit 

  • Mahmoud, that would be the seedValue. This is what you would pass into the subsequent CRC compute call.

  • Yes, that's correct, there is indeed a documented upper limit on this.

  • Typically when the values don't match, it's usually a case of the config parameters and pre and post-processing not matching up to what the online calculator is expecting. There are so many parameters here:

    Like:

    Seed value

    Flip or no Flip

    High-Low byte swap

    This is what I sent in a picture in one of my earlier mails i.e. what works for CRC32 and what works for CRC32-MPEG2.

    Thanks,

    Sira

  • i tried to pass the seed value but it didn't work, have a look here 

    result two should match result 3 but it didn't as you can see, result three matches the online calculator with flipping done 

  • Mahmoud,

    I'm a bit confused when I look at your previous picture of the definition of the generate_crc32c function - where it references Polynomial2 (0x1edc6f41) whereas your latest picture is trying to match up to CRC-32C where the polynomial specified is our Polynomial1 (0x04c11db7).

    1. So can you please send a picture showing your latest generate_crc32c function?

    2. In the online calculator tool, what does RefIn = true, RefOut = true mean? Does it mean the input is Reflected and so is the output?

    3. What does XOROUT = 0xFFFFFFFF mean? Does it mean the output (after Reflection) is XORd with 0xFFFFFFFF?

    4. What does the CHECK value refer to?

    Looking at your previous definition of generate_crc32c, I think the issue may be that your are computing the XOR on the intermediate results (e.g. result1), whereas you should do so only on the final output. So the XOR operation should be outside the generate_crc32c function.

    Thanks,

    Sira