David Schmidt wrote: > > Can someone point me to some on-line information on > how to create an Intel hex file? I need to write a > user interface for programming an EEprom and don't > know the format. Thanks in advance. Dave Dave I have a habit of saving snippets of information that I find usefull from the Piclist on my hardrive. Some time ago MarkHeuler posted the following info about inter Hex files. It helped me at the time. Rgds Werner Date: Wed, 4 Jun 1997 13:11:31 CET From: Marc 'Nepomuk' Heuler Subject: Re: Info needed on Hex file formats. Hi Rick (Rick Miller), in <199706031012.FAA29122@mail.execpc.com> on Jun 3 you wrote: > I wish I'd have kept all the stuff I got when I was in > the same boat... looking for info for building free > PIC development tools. If I remember right, the > format of the HEX file is detailed pretty extensively > on Parallax's site (www.parallaxinc.com, I think) > "somewhere". Could you be sure and relay that info to > the PICLIST when you've got it? Funny. Coincidentally, yesterday I did a several hour internet search for the hex file format. I am currently building a programmer as suggested in the "new programmer idea" thread. It connects to an RS232 port and parses an ASCII uploaded hex file for programming (9600bps 8N1, serial pics only, battery powered, small case). I do this because my HP200LX Palmtop does not talk to any other programmer I tried so far. Here's what I found about the hex file format: ******************************************************** ******** Below is a file representing the contents of a blank PIC16C54 as saved from the PRO MATE programmer screen buffer in INHX8M format. Below is a line of program data from the file: :10004000FF0FFF0FFF0FFF0FFF0FFF0FFF0FFF0F40 This is how the line can be broken down: column#: 01 0123 01 0123 0123 0123 0123 0123 0123 0123 0123 01 data type: BB AAAA TT HHHH HHHH HHHH HHHH HHHH HHHH HHHH HHHH CC data: 10 0040 00 FF0F FF0F FF0F FF0F FF0F FF0F FF0F FF0F 40 Data Types explained: The first two columns shown above (B1 and B2) are listed as data type BB. BB is the number of DATA BYTES that will appear on the line (two digits in hexadecimal). Note that for the PIC16C5X, the data word is 12 bits, represented as two bytes. B0 is the low byte and B1 is the high byte of the line count, so the bytes appear reversed. In this example BB=10, 16 decimal. This means there are 16 bytes on this line (or 8 12-bit program words). AAAA is the starting address (four digits in hexidecimal). Recall that the PIC16C5X is a 12 bit instruction word. Two data bytes are required to supply this data, with the upper nibble of the upper byte being 0 since it does not exist in the part. The address is incremented on the BYTE, NOT on the PROGRAM WORD. The address shown on the line is therefore double the address location the data will be programmed into. In this example AAAA = 0040, or decimal 64. The data in this line will be programmed to the part starting at the device address of 0020 hex, or 32 decimal (half the address value shown on the line). TT is record type designator. It will always be 00, except at the end of file record which is set to 01. HHHH is the two byte data word to be programmed into the part. Note that they are ordered least significant byte first, then most sigificant byte. Since in this example the part is blank, all of the locations are 0FFF hex. However the data actually appears as FFF0. In other words, columns H0 and H1 make up the lower byte (FF, with H0 as Most Significant Byte) and columns H2 and H3 make up the upper byte (0F, with H2 as MSB). CC is the two-digit hexadecimal checksum that is the two's complement of the sum of all the preceding bytes in the record including the byte count. (10 + 00 + 40 + 00 + FF + 0F + FF + 0F + FF + 0F + FF + 0F + FF + 0F + FF + 0F + FF +0F + FF + 0F) = 08C0 hex. Two's compliment (invert and add one) is F740. When truncated to one byte it is 40 hex, which is the number shown in the example. Below is the third to last line as shown in this file. It contains the information for the ID locations. In the PIC16C5X there are four ID locations, starting at 200 hex, and only the lower nibble of each location is programmed. When viewed in the current revision of PRO MATE the four nibbles are shown together. When blank they are displayed as FFFF hex on the screen. However when the part is programmed, the data actually goes to four separate bytes locations 200 to 203 hex. Each unprogrammed ID location is therefore represented as 000F hex in this programming file. :080400000F000F000F000F00B8 The line shown below is for the configuration word. It is the second to last line, as shown in this file. (the last line is the end of record line) :021FFE00FF0FD3 There are two bytes, as stated by the 02. They are programmed at 1FFE divided by two, or FFF hex. In this case the configuration word is blank, so it is 0FFF hex. Below is an example of the same line from a part with the configuration word programmed to WDT enabled, Code protect on, LP mode. :021FFE00F00FE2 Notice that this time the part will be programmed with FF0 in the configuration word. Only the lower four bits are used in the PIC16C5X to program the configuration word, and in this case they are all programmed. There may be subtle differences from this file to those for other parts, since configuration word and ID locations may be handled differently. ------------------------------ -- Werner Terreblanche http://users.iafrica.com/w/we/wernerte/index.htm wterreb@plessey.co.za (work) OR wernerte@iafrica.com (home) Plessey SA, PO Box 30451,Tokai 7966, Cape Town, South Africa or at home : Suite 251, PostNet X5061, Stellenbosch, 7599 Tel +27 21 7102251 Fax +27 21 7102886 Home +27 21 8872196 ------------------------------------------------------------