PDA

View Full Version : How to Generate the INTEL HEX File?


shidlingayya
February 6th, 2008, 06:07
Dear Sir,
I am Shidlingayya..presently i am working for Siemens from past one year
i am facing some problem in generating the INTEL HEX File

Problem-> How to Convert EEPROM Data into INTEL HEX File format
i am using following tool for my compilation...
-VC++ compiler(Editor)
-IAR Compiler
-NEC microcontroller
-PERL(Linux Envirnoment)
Is there any way to generate the Intel Hex file from Any of these tools..if some procedure is there please tell me where i can get some more details about my requirement....
Thanks & Regards
Shidlingayya

tHE mUTABLE
February 6th, 2008, 09:56
Try 010 Editor

blabberer
February 6th, 2008, 15:52
what is your question ? you want the compilers to output hex format directly ??
i dont think it is feasible at least not with vc

what is eeprom data
do you have an executable that you compiled ??

if you have an exe as output from these compilers then you can check out a few exetohex convertors

Code:

EXEHEX - A Microsoft EXE to Intel HEX file converter
This program converts Microsoft .EXE files to Intel HEX files
suitable for burning into EPROM. Like the loader in MSDOS,
exehex performs any necessary relocation of segments in the
.EXE file.


google gave me this in one search

http://www.programmersheaven.com/download/3177/download.aspx

Code:

EXEHEX

This program is used to convert Microsoft .EXE files to Intel HEX files that are suitable for burning into EPROM.

You CANNOT simply take your favorite program such as Microsoft WORD, and expect
the exehex program make it work in EPROM. You must write the programs to be
used with this utility carefully, and with the full intent of running them on
an embedded 80x86 microprocessor system.

Some things that must be done to be successful:

1) Write a simple jump vector program in MASM that will reside in EPROM at
address FFFF:0000. This program should consist of something like this for
an 8086/8088:

PwrInit segment para public 'Code'
Public Power_Start
Power_Start proc far
org 0
; jmp far ptr 0F000:0000H ;MASM won't allow this, so...
db 0EAH ;fake a far jump to EPROM start
dd 0F0000000H ;(segment)(offset)

Power_Start endp
PwrInit ends
end


Then after linking with Microsoft linker, you pass the file thru
exehex like this:

exehex -SFFFF -O0000 powerini.exe powerini.hex

This startup vector is setup to reside at FFFF:0000 in EPROM, and to jump
to the first location in EPROM where your program will begin.

2) Write a short chunk of code that will reside at the first location in your
EPROM (in this case F000:0000). This code will setup the segment registers,
stack, interrupt vectors, copy initialized data to ram, and then when done,
will branch to your application program.

EPROMST segment para public 'Code'
Public EPROM_Begin
EPROM_Begin proc near
org 0
xor ax,ax ;this example assumes 64K of RAM
mov ds,ax
mov es,ax
mov ss,ax
mov sp,STACK_TOP

xor si,si ;int vectors start at offset 0
mov cx,256 ;number of possible interrupt vectors

mov ax,0000H ;set all vectors to power restart
mov dx,0FFFFH ;they should really go to default handler.
IV_Loop:
mov [si],ax
add si,2
mov [si],dx
add si,2
loop IV_Loop
.
.
jmp Your_Code_Begin

EPROM_Begin endp
EPROMST ends
end

Then link your code, and pass it thru exehex like this:

exehex -SF000 -O0000 -N yourcode.exe yourcode.hex

3) Cat your power start vector to your linked code:

copy yourcode.hex + powerini.hex EPROM.HEX

4) Burn EPROM.HEX using your favorite method of burning intel hex files, and
watch your project come to life.

5) Be sure to include a file that defines the segment ordering with every
assembly language file in the program. For example:

.seg ;say you want segments in order shown
EPROMST segment para public 'Code'
EPROMST ends

Code segment para public 'Code'
Code ends

PwrInit segment para public 'Code'
PwrInit ends

6) Be sure and present the Code segment files to the the linker in the same
order that you want them to appear in EPROM. (eg. it would be handy to
have your startup code appear first in the EPROM. ;-) )

7) Initialized data segments must not appear in the assembled output. If you
want to initialize data, you must put that data into the EPROM in the code
segment. If you want to be able to change the value of the initialized
data, you must make your program copy the data into the proper location in
RAM, and use it there (eg, the data must have the same offset it had in
EPROM, but just be in the RAM segment).

I have examples of startup code for 80186/80188 processors too, If you really
need them, something can be arranged. Bear in mind that I do this embedded
processor stuff as my sole means of support and livelyhood, not just for fun.

Good Luck, If you have any questions, comments, or bug reports, I can be
reached by email at: chuck@eng.umd.edu or:


Chuck Harris

C.F. Harris - Consulting
9308 Canterbury Riding
Laurel, Maryland 20723
(301)490-7443

SiGiNT
February 16th, 2008, 04:01
Most of the Eprom CPLD, and PLD firmware I've seen is not Hex, but binary, in ascii format, usually the chip manufacturer or the programing hardware comes with simple Basic type editor and a compiler - however nothing is stopping you if you really want dig deep and and do it by hand - our firmware guys at work seem to like UltraEdit as an all purpose tool.

SiGiNT