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.

UCD3138A64: UCD3138A64 checksum calculation.

Part Number: UCD3138A64
Other Parts Discussed in Thread: UCD3138064, UCD3138

Hello,

I have to develop a firmware to compare the checksum of the Flash memory of the UCD3138A64 (once it is programmed - using the command 0xEF) and the checksum of the source file that I previously programmed inside the target memory. This is necessary to verify if my firmware is correctly programmed inside the MCU.

For the UCD3138064 I did a comparison using a checksum calculated with a byte sum.

With the new UCD3138A64 I'm not able to do a correct comparison. I tried to do a sum of all the bytes and also a sum of 32bits words, but the result is always a failure.

Which is the method that I have to use to calculate the checksum?

Thank you.

Best Regards,

Giovanni

  • To speed up the code, we did it a 32 bit word at a time. It takes them as unsigned 32 bit ints. Here's the code:

    void calculate_checksum(register Uint32 *start_address, register Uint32 *end_address)
    {
    register unsigned long long lcs = long_checksum; //use local register variable for speed.

    while(start_address < end_address)
    {
    lcs = lcs + *start_address ;
    lcs = lcs + (Uint32)*(start_address + 1) ;
    start_address = start_address + 2;
    }
    long_checksum = lcs;
    }
    We do them 2 at a time to speed things up a bit - reduces the loop overhead by a factor of 2.
    Note that the result is a long long - 64 bits. So we use 8 bytes to store the checksum.

    It gets sped up by a factor of 4. The 32K checksum on the UCD3138 takes about 10 msec, while the 64K one here takes about 5.
  • Hello Mr. Bower,

    with your suggestions I solved the issue.

    Thank you very much!

    Best Regards,

    Giovanni Salvador