Cart New Account Login

HomeAbout usProductsSupportForumsBlogCustomer Service

search inside this forum
Checksum
fei l. Nov 20, 2017 at 04:26 AM (04:26 hours)
Staff: Huajun L.

  • 用command line proghcs08.exe 从freescale8705型号芯片中读取S19文件,S19的命令为S113,我想知道它的校验是怎么计算的?我在网上查到的资料都是0xFF-0xNN,但是我用这种方式计算出来并不对,请以下列两行数据为例,谢谢。
    S113C000018D53A601CDCE84CDC1A4CDCE3A4FCD62
    S113C010CD07118D2040C718000D8F0E1D8FCDC187




    Comments

  • First of all, S19 record is formatted as following:

    Header: S1 or S2 or S3 where the number designates how many bytes are in the address field. 1 corresponds to 2-byte address in the S-record, 2 corresponds to 3-byte address, and 3 corresponds to 4-byte address.

    In this example, there are two bytes address (e.g. C000 and C010)

    Length: The first byte after header designates how many bytes following in the line, including the last checksum byte.

    In this example, the total number of bytes are 13 (19 in decimal format).

    Address: two or three or four bytes address depending on the number in the header.

    In this example, the addresses are C000 in the first line, and C010 in the second line.

    Data: There are a total of (length - number of address bytes - 1) bytes of data.

    In this example, both lines have (19 - 2 - 1 = 16) bytes of data (0x10 hex).

    Checksum: This checksum is calculated by simply add up all bytes together starting with the length field till the end of data, then exclusive or the sum with 0xFF.

    e.g. the first line the sum is
    13+C0+00+01+8D+53+A6+01+CD+CE+84+CD+C1+A4+CD+CE+3A+4F+CD = 0x99D.
    Take the data byte and exclusive or it with 0xFF: 9D xor 0xFF = 62

    Similarly for the second line, the sum is:
    13+C0+10+CD+07+11+8D+20+40+C7+18+00+0D+8F+0E+1D+8F+CD+C1 = 0x678.
    Take the data byte and exclusive or it with 0xFF: 78 xor 0xFF = 87

    I hope this helps.

    Best Regards
    Huajun

Add comment


   Want to comment? Please login or create a new PEMicro account.







© 2017 P&E Microcomputer Systems Inc.
Website Terms of Use and Sales Agreement