Hex File Format (2024)

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.

Hex File Format (1)

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.

Filed Under: Tutorials
Tagged With: hex, hex file, microcontroller

Hex File Format (2024)

FAQs

What is a hex file? ›

The Intel HEX file is an ASCII text file with lines of text that follow the Intel HEX file format. Each line in an Intel HEX file contains one HEX record. These records are made up of hexadecimal numbers that represent machine language code and/or constant data.

What program opens a hex file? ›

Windows Notepad

If you don't have a hex editor installed, you can use the Windows built-in notepad program to open the hex file.

How to read a .hex file? ›

Hex File Format
  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. ...
  3. XXXX….. ...
  4. SS is the checksum byte of that line.

Why do we need a hex file? ›

You can use a Hexadecimal (Intel-Format) File (. hex) in the Quartus® Prime software to store the initial memory values for a memory block, such as RAM or ROM, that is implemented in an FPGA device, or to build software project executables.

What tool is used to read hex files? ›

Hex Viewer is used to view or examine the raw constituents of an item—file, process, data source, or even a partition—from a case or standalone file. Hex Viewer consists of 2 panes: Raw data and Type converter.

What does hex format look like? ›

The hexadecimal system contains 16 sequential numbers as base units, including 0. The first nine numbers (0 to 9) are the same ones commonly used in the decimal system. The next six two-digit numbers (10 to 15) are represented by the letters A through F.

Can Notepad++ open hex files? ›

Encoded text files can be edited with Notepad++, but a hex editor plugin is available to make the process easier. To edit files, especially in hex format, sometimes known as hexadecimal, you will need to install Notepad++ Hex Editor Plugin.

How to convert code into hex file? ›

You need a compiler (and an assembler and a linker), also known as a toolchain. The compiler converts your C program source code into executable object code for your target machine. This object code can be represented as a series of hex digits in a . hex file.

Does Microsoft have a hex editor? ›

Quick Hex Editor - Download and install on Windows | Microsoft Store.

How do I convert to hex format? ›

Method for Decimal to Hexadecimal Number System Conversion:

Step-1: First, divide the given number by 16. Step-2: The remainder left here, will produce the hex value. Step-3: Take the quotient from above and repeat steps 1-3 till quotient becomes 0. Step-4: Write all the remainders in reverse order.

How is hex displayed? ›

The HEX command displays each row of data on three lines. One line is in the standard text representation of the data and two are used for the hexadecimal representation. The hexadecimal representation is shown as two digits directly under each EBCDIC character.

Where is the hex file? ›

Within the dist\<configuration> directory, the HEX file will be found in the production subdirectory.

What app opens hex files? ›

Hex Viewer is an ultra-simplistic app that you can use to view the hexedecimal code of any file, regardless of its format. An app for viewing the binary data, the data is represented in the "raw" - as a sequence of bytes. This Viewer does not save or share the file you select.

What is hex used for? ›

Software developers and system designers widely use hexadecimal numbers because they provide a convenient representation of binary-coded values. Each hexadecimal digit represents four bits (binary digits), also known as a nibble (or nybble).

What is hex and why is it used? ›

Hex is useful because large numbers can be represented using fewer digits. For example, colour values and MAC addresses are often represented in hex. Additionally, hex is easier to understand than binary. Programmers often use hex to represent binary values as they are simpler to write and check than when using binary.

What is a hex code used for? ›

Hex codes are a hexadecimal format for identifying colors. This is a system used in HTML, CSS and SVG. Each hex code refers to a very specific color, which allows for two designers or a designer and developer to be on the same page about what exact light blue (or any other color) they are referring to.

What does a hex viewer do? ›

Hex Viewer is a plugin for Sublime Text that allows the toggling of a file into a hex viewing mode. Hex Viewer also supports hex editing.

References

Top Articles
Latest Posts
Article information

Author: Allyn Kozey

Last Updated:

Views: 6270

Rating: 4.2 / 5 (63 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Allyn Kozey

Birthday: 1993-12-21

Address: Suite 454 40343 Larson Union, Port Melia, TX 16164

Phone: +2456904400762

Job: Investor Administrator

Hobby: Sketching, Puzzles, Pet, Mountaineering, Skydiving, Dowsing, Sports

Introduction: My name is Allyn Kozey, I am a outstanding, colorful, adventurous, encouraging, zealous, tender, helpful person who loves writing and wants to share my knowledge and understanding with you.