What is an Intel HEX File?
- An Intel HEX file is an ASCII text-based file format used for representing binary data.
- It's commonly used to transfer program code and data to microcontrollers and other embedded systems.
History
The Intel HEX file format was introduced by Intel in the 1970s. It has since become a standard in the industry for firmware and microcontroller programming.
Structure of an Intel HEX File
SYNTAX of each record
- Each record follows a specific syntax = :llaaaatt[dd...]cc
- It has 5 fields as denoted above.
- Each letter denotes a hexadecimal digit.
- Each field is made up of a minimum of 2 hexadecimal digits.
- Hence, denotes 1 byte each.
Record Types - ‘tt’ field
There are six main types of records in an Intel HEX file:
- Type 00 - Data Record
- Type 01 - End of File Record
- Type 02 - Extended Segment Address Record
- Type 03 - Start Segment Address Record
- Type 04 - Extended Linear Address Record
- Type 05 - Start Linear Address Record
Calculation of Checksum
- Considering two hex digits at a time, add all hex pairs until the ‘dd’ field.
- Convert the hex sum to decimal. If the Hex Sum contains 3 digits, ignore the first digit (MSB), and convert the remaining 2 digits to decimal.
- Subtract the above decimal sum from 256.
- Convert the result back to hex. Hence, this hex output will be the required Checksum.
EXAMPLE 1:
Considering the Intel HEX record :03000000020C1F
Sum of all Hex Pairs: 03H + 00H + 00H + 00H + 02H + 0CH + 1FH = 30H
Converted Decimal Output: 48
256 - Decimal Output: 208
Checksum: D0H
Complete Intel HEX record with checksum :03000000020C1FD0
EXAMPLE 2:
Considering the Intel HEX record
:10080000E517240BF8E60517227808300702780B
Sum of all Hex Pairs:
10H + 08H + 00H + 00H + E5H + 17H + 24H + 0BH +F8H + E6H + 05H + 17H +
22H + 78H + 08H + 30H + 07H + 02H + 78H + 0B = 49BH
(Ignoring 4 (MSB) for step 2)
Converted Decimal Output: 155
256 - Decimal Output: 101
Checksum: 65H
Complete Intel HEX record with checksum
:10080000E517240BF8E60517227808300702780B65
For a detailed walkthrough, including practical demonstrations and more in-depth analysis, do watch our YouTube video on Checksum Calculation for Intel HEX File Format
Video Link: Checksum Calculation for Intel HEX File Format
Call to Action
If you found this post helpful, please like and subscribe to our YouTube channel for more educational content on digital communications, embedded systems and other exciting topics.
Feel free to leave your comments and questions below or on our video, and we’ll be happy to engage with you.
Comments
Post a Comment