This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

0x0-0xFA00 checksum calculation

Hi there!

Can anybody help me with my problem?

If I calculate checksum from 0x0 to 0x3000 - it is OK.
But if I want to calculate 0x0 to 0xFA00 range - checksum is different every microcontroller reboot. I wrote programm in flash and start MK from there, not as bootstrap. Checksum shows at LCD.

Thanks

Some data:
Shecksum calculation procedure:

 unsigned char CheckChecksum (void)
{
        unsigned char *start_addr;
        unsigned int len, step, i = 0;
        unsigned char checksum = 0;

         start_addr = 0x000;
        len = 0xFA00;//0x3000;

        step = len / 22;

        ShowCalcCheckSum( len ); // Out some info on LCD

        for (i = 0; len > 0; len--, start_addr++, i++)
        {
                checksum += *start_addr;

                 if ( i == step )
                {
                        WriteByte(0x0,1);
                        i = 0;
                }

        }


        FlashChecksum = checksum;

        return checksum;
}

.BAT file for insert correct checksum in hex-file

c:\keil\uv3\hex2bin %1.H86
c:\keil\uv3\check8  %1.bin /s0x00 /e0xF9FE /p0xF9FF /v0x80
c:\keil\uv3\bin2hex %1.bin %1a.H86

.

0