The Intel hex (ihex) generally known as hex file, is a format used to store machine language code in hexadecimal form. It is widely used format to store programs to be transferred to microcontrollers, ROM and EEPROM. The compilers convert the programs written in assembly, C etc into corresponding hex files, which are dumped into the controllers using burners/programmers. This article explores the details of the hex file format.
The microcontroller understands machine language consisting of zeroes and ones. It’s difficult rather practically impossible for humans to write codes in zeros and ones. Hence we use some high level languages like C, C++, Java, etc. And later a compiler is used to convert these codes into machine language which are stored in a hex file format. A hex file is a text file with the extension .hex.

Fig. 1: Image of a Hex File shown as Text
The above image shows a typical hex file when opened with notepad or any other text editor. Every line follows a specific structure explained below.
:CCAAAATTXXXXX……XXSS
Example:
:100000000C942A000C9434000C9434000C943400AA
1. Every line in a hex file always starts from colon (:)
2. The first two digits CC (Character Count) represent the total number of data byte in that line. Here in this example, 10 (hexadecimal) are the first two digits which mean that there is 16 byte (in decimal) of data in the line.
3. The next four digits represent the starting address of the memory where the data stored in the line needs to be dumped. 4. After address the next two digits represent whether this is the last line of code or not. TT=0, means the code is not complete and there are more lines after this line and TT=1 means this is the last line of the code.
5. XXXX…..XX are the data bytes which have to be dumped into the memory. The number of data bytes in a particular line is equal to the number indicated by character count digits (CC).
6. SS is the checksum byte of that line.
The hex file is a text file so one can easily change contents of a hex file. The corrupted line can be identified using the check sum) (SS) byte.
You may also like:
Filed Under: Tutorials
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.