问答

汇集网友智慧,解决技术难题

21ic问答首页 - MPLAB X IDE中使用hexmate工具生成的16位checksum问题

hexmate checksum

MPLAB X IDE中使用hexmate工具生成的16位checksum问题 赏100家园币

JackTang19942022-07-28
请问下,我在使用hexmate生成的16位checksum与hexmate手册中CheckSum算法代码所生成checksum不一样?以下为hexmate用户手册7.1.1 Addition Algorithms中的checksum生成代码
#include <stdint.h>
typedef uint8_t read_t; // size of data values read and summed
typedef uint16_t result_t; // size of checksum result
// add to offset, n additions of values starting at address data,
// truncating and returning the result
// data: the address of the first value to sum
// n: the number of sums to perform
// offset: the intial value to which the sum is added
result_t ck_add(const read_t *data, unsigned n, result_t offset)
{
result_t chksum;
chksum = offset;
while(n--) {
chksum += *data;
data++;
}
return chksum;
}



实际工程中的checkSum设置:
hexmate ${ImagePath} -FILL=0x3FFF@0x0000:0x7FFB -CK=0x0800-0x0802@0x7FFC+0x00w-2t34g1 -o${ImagePath}
在MPLAB X IDE的Program Memory窗口中查看到的0x400地址处内容为0x3184,如果按照上述checkSum计算方法得到的checksum值为B5,而使用hexmate生成的checksum值为C9

请问下,到底这个hexmate生成的16位checksum算法是怎样的?
回答 +关注 5
29642人浏览 7人回答问题 分享 举报
7 个回答

您需要登录后才可以回复 登录 | 注册