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.
Hello all,
I am reading the UID_REGS from CPU1 in a TMS320F28377D and the data I get is:
0xF812BFAC,0xA22B53BD,0xAE14429C,0x32DAB547,0x43D9B0A0,0xF3659489,0x000C0E3C,0xD3D5112D
and, as the manual says, the last data (0xD3D5112D) is called UID_CHECKSUM and is the 32-bit fletcher checksum of the previous data.
When I try to calculate it myself, the result I get is 0x8011112D instead of 0xD3D5112D. The algorithm I use is this one:
uint32_t fletcher32( uint16_t const *data, size_t words )
{
uint32_t sum1 = 0xffff, sum2 = 0xffff;
while (words)
{
unsigned tlen = words > 359 ? 359 : words;
words -= tlen;
do {
sum2 += sum1 += *data++;
} while (--tlen);
sum1 = (sum1 & 0xffff) + (sum1 >> 16);
sum2 = (sum2 & 0xffff) + (sum2 >> 16);
} /* Second reduction step to reduce sums to 16 bits */
sum1 = (sum1 & 0xffff) + (sum1 >> 16);
sum2 = (sum2 & 0xffff) + (sum2 >> 16);
return sum2 << 16 | sum1;
}
I have also testet other versions of the 32-bit fletcher Checksum algorithms but the result is the same. Could anybody tell what it is wrong?
Many thanks in advance,
Andreu
Hi Joseph,
You are right: Now it works for me too. Many thanks for your help!
Regards,
Andreu