C언어 > INTEL HEX FILE FORMAT

TODAY1,287 TOTAL677,630
사이트 이용안내
Login▼/회원가입
최신글보기 질문게시판 기술자료 동영상강좌

아두이노 센서 ATMEGA128 PWM LED 초음파 AVR 블루투스 LCD UART 모터 적외선


BASIC4MCU | C언어 | C언어 | INTEL HEX FILE FORMAT

페이지 정보

작성자 키트 작성일2017-09-12 11:37 조회477회 댓글0건

본문

GENERAL: INTEL HEX FILE FORMAT

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. Intel HEX files are often used to transfer the program and data that would be stored in a ROM or EPROM. Most EPROM programmers or emulators can use Intel HEX files.

Record Format

An Intel HEX file is composed of any number of HEX records. Each record is made up of five fields that are arranged in the following format:

<PRE>:llaaaatt[dd...]cc</PRE>

Each group of letters corresponds to a different field, and each letter represents a single hexadecimal digit. Each field is composed of at least two hexadecimal digits-which make up a byte-as described below:

  • : is the colon that starts every Intel HEX record.
  • ll is the record-length field that represents the number of data bytes (dd) in the record.
  • aaaa is the address field that represents the starting address for subsequent data in the record.
  • tt is the field that represents the HEX record type, which may be one of the following:
    00 - data record
    01 - end-of-file record
    02 - extended segment address record
    04 - extended linear address record
  • dd is a data field that represents one byte of data. A record may have multiple data bytes. The number of data bytes in the record must match the number specified by the ll field.
  • cc is the checksum field that represents the checksum of the record. The checksum is calculated by summing the values of all hexadecimal digit pairs in the record modulo 256 and taking the two's complement.

Data Records

The Intel HEX file is made up of any number of data records that are terminated with a carriage return and a linefeed. Data records appear as follows:

:10246200464C5549442050524F46494C4500464C33

This record is decoded as follows:

:10246200464C5549442050524F46494C4500464C33||||||||||| CC->Checksum|||||||||DD->Data|||||||TT->Record Type|||AAAA->Address|LL->Record Length:->Colon

where:

  • 10 is the number of data bytes in the record.
  • 2462 is the address where the data are to be located in memory.
  • 00 is the record type 00 (a data record).
  • 464C...464C is the data.
  • 33 is the checksum of the record.

Extended Linear Address Records (HEX386)

Extended linear address records are also known as 32-bit address records and HEX386 records. These records contain the upper 16 bits (bits 16-31) of the data address. The extended linear address record always has two data bytes and appears as follows:

:02000004FFFFFC

where:

  • 02 is the number of data bytes in the record.
  • 0000 is the address field. For the extended linear address record, this field is always 0000.
  • 04 is the record type 04 (an extended linear address record).
  • FFFF is the upper 16 bits of the address.
  • FC is the checksum of the record and is calculated as
    01h + NOT(02h + 00h + 00h + 04h + FFh + FFh).

When an extended linear address record is read, the extended linear address stored in the data field is saved and is applied to subsequent records read from the Intel HEX file. The linear address remains effective until changed by another extended address record.

The absolute-memory address of a data record is obtained by adding the address field in the record to the shifted address data from the extended linear address record. The following example illustrates this process..

<PRE>Address from the data record's address field 2462Extended linear address record data field FFFF --------Absolute-memory address FFFF2462</PRE>

Extended Segment Address Records (HEX86)

Extended segment address records-also known as HEX86 records-contain bits 4-19 of the data address segment. The extended segment address record always has two data bytes and appears as follows:

:020000021200EA

where:

  • 02 is the number of data bytes in the record.
  • 0000 is the address field. For the extended segment address record, this field is always 0000.
  • 02 is the record type 02 (an extended segment address record).
  • 1200 is the segment of the address.
  • EA is the checksum of the record and is calculated as
    01h + NOT(02h + 00h + 00h + 02h + 12h + 00h).

When an extended segment address record is read, the extended segment address stored in the data field is saved and is applied to subsequent records read from the Intel HEX file. The segment address remains effective until changed by another extended address record.

The absolute-memory address of a data record is obtained by adding the address field in the record to the shifted-address data from the extended segment address record. The following example illustrates this process.

<PRE>Address from the data record's address field 2462Extended segment address record data field 1200 --------Absolute memory address 00014462</PRE>

End-of-File (EOF) Records

An Intel HEX file must end with an end-of-file (EOF) record. This record must have the value 01 in the record type field. An EOF record always appears as follows:

:00000001FF

where:

  • 00 is the number of data bytes in the record.
  • 0000 is the address where the data are to be located in memory. The address in end-of-file records is meaningless and is ignored. An address of 0000h is typical.
  • 01 is the record type 01 (an end-of-file record).
  • FF is the checksum of the record and is calculated as
    01h + NOT(00h + 00h + 00h + 01h).

Example Intel HEX File

Following is an example of a complete Intel HEX file:

:10001300AC12AD13AE10AF1112002F8E0E8F0F2244

:10000300E50B250DF509E50A350CF5081200132259

:03000000020023D8

:0C002300787FE4F6D8FD7581130200031D

:10002F00EFF88DF0A4FFEDC5F0CEA42EFEEC88F016

:04003F00A42EFE22CB

:00000001FF

 

http://www.keil.com/support/docs/1584.htm

 

바이너리파일(.bin)은 특정 번지부터 연속된 데이터로 채워져 있어야 합니다.

HEX 파일은 HEXASC 코드 형태로 실제 데이터에 비해서 크기는 2배~3배의 크기로 크지만

라인에 어드레스를 기입 하므로 건너띠는 데이터의 경우에는 .BIN 파일보다 작아질 수도 있습니다.

각 라인 끝에는 첵섬이 있으므로 데이터 신뢰성도 높아서 많이 사용하는 포멧입니다.

댓글 0

조회수 477

등록된 댓글이 없습니다.

C언어HOME > C언어 > 전체 목록

게시물 검색

2019년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2018년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
Privacy Policy
MCU BASIC ⓒ 2017
모바일버전으로보기