Checksum calculation in AN2399

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Checksum calculation in AN2399

1,675件の閲覧回数
Magnus
Contributor I
Hi!
 
In AN2399 it says that the checksum is calculated as the 1's complement of the sum of flash memory from 0xF600 to 0xF7FD, but in the example firmware code (last row in icp-kbd.asm in AN2399SW.ZIP) I can see it is calculated as the two's complement. I have verified this by using the CHECKSUM_ADD method in the .prm file and calculated it myself.
 
This is what I added in the default.prm file:
 
CHECKSUM
    CHECKSUM_ENTRY
        METHOD_ADD SIZE 1
        OF      READ_ONLY   0xF600 TO 0xF7FD
        INTO    READ_ONLY   0xF7FE SIZE 2
        UNDEFINED 0xFF
    END
END
 
Then I just did a one's complement of the sum and got the value 0x0994.
But in the last row in source file icp-kbd.asm it says:
 
dc.w $0995     ;;ICP_Flag (Checksum) 
 
And also, in JB16_ICP.ASM in AN2399 it is just calculated as the sum with no complement.
 
What method is the correct one to use? 1's complement, 2's complement or just the sum?
 
 
ラベル(1)
0 件の賞賛
返信
1 返信

464件の閲覧回数
Encoder
Contributor I
Usually for checksum purpose you must add the simple sum of your data list with the known complemented sum to achieve a fixed value, i.e. $FFFF (not $0000).
 
This may well be one's complement
 
Encoder
0 件の賞賛
返信