Page 87
5.14.2 Description of
Intel‑HEX File Format
Intel-HEX are text files consisting of lines.
Each line has the following structure:
:LLAAAATTDDDD...CC
„:“ Each line in a file must start with this
character (colon, 0x3A).
LL Length of record (number of DD fields).
AAAA Address of record's first byte.
TT Record type. The types may be:
00 - Data
01 - End of file. Each file must finish with
this record.
02 - Extended segment address. (32-bit
Intel-HEX only)
04 - Extended linear address. (32-bit
Intel-HEX only)
There are also other types like 03 and 05, which are
ignored by UP while reading and not used for saving.
DD Record data. The number of bytes must be
exactly LL.
CC Checksum. The check sum is computed as
a binary supplement to the sum of all
values on the line.
Data Record
A line with the configuration memory of a 14-bit device is
used here as an example.
:02400E00413F30
02 Record length. The configuration memory
size is one word = 14 bit = 2 byte (byte
alignment).
400E Record address. The configuration memory
address is the word 2007h addressed by
bytes, i.e. 400Eh.
00 Record type = data
413F Record data. Configuration word =3F41h
30 Check sum. 30 = 02 + 40 + 0E + 00 + 41
+ 3F = xxD0; neg D0 = 30
End of File
The only acceptable alternative of the End of file line is:
:00000001FF
Extended Linear Address
Only files that need to address more than 64 kB of the
addressed space contain this line.
For example, processors of the PIC18F family have their
configuration memory saved at the address 0x 30 00 00
00.
If this address needs to be used, it is necessary to insert a
line in the .hex file specifying the extended linear
address, i.e. the upper 16 bites of the address. The lower
16 bits are read from the line with the data record.
:020000040030CA
This line selects the configuration memory of PIC18F
family devices.
The extended segment records specify the segment, i.e.
bits 19-4 of the address, which are then added to
addresses from the data records (offset).