PIC24F Checksum Calculation
Posted: Fri Jun 22, 2018 10:13 pm
I recently signed up on the Microchip forum and have been unable to post there since I signed up.
I could use some help figuring out what I'm missing. Calculating the checksum of the PIC24F looks to be straightforward, according to section 6.1 from DS39919C - PIC24FXXKA1XX/FVXXKA3XX Flash Programming Specification - (see attached screen capture) the checksum is just the 16bit byte sum (one byte at a time) of the configuration block (only lower two bytes are summed) and the program memory (all 3 bytes are summed). There are two examples in the datasheet, but I'm not even get the first to work out:
I am using a PIC24F32KA302, and the erased checksum is given as 0x8158. If I add the configuration block (masked as shown in the datasheet) a PIC24FV32KA302 with default configuration block values would be 0x000F + 0x0003 + 0x00E7 + 0x00FF + 0x00FF + 0x00FF + 0x0083 + 0x00DF = 0x0558. I'm not sure what I need to change to get 0x8158. I've tried various modifications such as taking the inverse or the 2's complement but I'm just not getting there. I've searched the forums extensively as well as the internet and am not finding anything to get this to work.
Hopefully, if I can get past this, then the next step of calculating the checksum once we add in the program memory will be straightforward.
Any clues?
I could use some help figuring out what I'm missing. Calculating the checksum of the PIC24F looks to be straightforward, according to section 6.1 from DS39919C - PIC24FXXKA1XX/FVXXKA3XX Flash Programming Specification - (see attached screen capture) the checksum is just the 16bit byte sum (one byte at a time) of the configuration block (only lower two bytes are summed) and the program memory (all 3 bytes are summed). There are two examples in the datasheet, but I'm not even get the first to work out:
I am using a PIC24F32KA302, and the erased checksum is given as 0x8158. If I add the configuration block (masked as shown in the datasheet) a PIC24FV32KA302 with default configuration block values would be 0x000F + 0x0003 + 0x00E7 + 0x00FF + 0x00FF + 0x00FF + 0x0083 + 0x00DF = 0x0558. I'm not sure what I need to change to get 0x8158. I've tried various modifications such as taking the inverse or the 2's complement but I'm just not getting there. I've searched the forums extensively as well as the internet and am not finding anything to get this to work.
Hopefully, if I can get past this, then the next step of calculating the checksum once we add in the program memory will be straightforward.
Any clues?