18.11.2014 Views

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 13<br />

Intel Hex<br />

Like ASCII Hex, Intel Hex format stores bytes as ASCII codes representing hexadecimal<br />

characters. But Intel Hex adds addressing and error-checking information for more flexible<br />

programming and more reliable file transfer.<br />

Each Intel Hex file consists of a series of records. Table 13-1 has more details about the<br />

records and what they contain. You don’t have to understand everything about Intel Hex<br />

format in order to use it, but the information can be useful if you run into problems and want<br />

to examine the contents of a file.<br />

Assembling a Program<br />

When you assemble a program, the message Assembly Successful, or something similar,<br />

means that the assembler found no errors that prevented it from creating the object file. If<br />

you do see error messages, you’ll have to find out what’s wrong before continuing. <strong>The</strong><br />

listing file also includes the error messages, and these should help you track down any<br />

problems.<br />

Table 13-1. An Intel Hex file consists of a series of records , each of which<br />

contains the the six elements below.<br />

Name # Chars Description<br />

Record Mark 1 Each record begins with a colon (:).<br />

Record Length 2 Number of data bytes in the record.<br />

Address Field 2 In data records, the address where the first data byte is to be stored, with<br />

following bytes in sequence. In other record types, 0000.<br />

Record type 2 <strong>The</strong>re are four record types:<br />

00 Data<br />

01 End of File<br />

02 Extended address<br />

03 Start address<br />

Data Field varies Contents depends on the record type:<br />

00 Data to be programmed<br />

01 Not used (empty)<br />

02 Segment. For address fields larger than 64K, data is stored<br />

beginning at (segment+10h)+address field.<br />

03 Start address of program. Often unused.<br />

Checksum 2 To calculate the checksum:<br />

(1) Add the values of all of the bytes in a record.<br />

(2) Take the 2’s complement of the result (Complement all bits and<br />

add 1.)<br />

(3) <strong>The</strong> checksum is the low byte of the result.<br />

224 <strong>The</strong> <strong>Microcontroller</strong> <strong>Idea</strong> <strong>Book</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!