I am new to Embedded systems. I am starting my learning with AT89C51. My first target will be LCD interfacing.

I have a programmer an LCD and a microcontroller.

But the program is written in C or assembly language and I need a .HEX file to burn.

How do I do this? I have also heard about Keil IDE but its evaluation version is not working. Please help me with any additional information.

  • \$\begingroup\$ where will be the hex file stored \$\endgroup\$
    – user11621
    Aug 19, 2012 at 7:16

3 Answers 3


You need a compiler (and an assembler and a linker), also known as a toolchain.

The compiler converts your C program source code into executable object code for your target machine. This object code can be represented as a series of hex digits in a .hex file.


SDCC is a free compiler which supports the AT89C51.


As Joby said, you need a toolchain. There are a number of steps which have to happen between the C code you have and loading data onto the device:

  • The preprocessor converts #include and #define macros, and also processes any conditional compilation (#if) symbols.
  • The compiler converts each .c file into assembly code.
  • The assembler converts those into object files. These files use relative addressing.
  • The linker puts all the object files together into the series of hex digits in the .hex file, and gives them the addresses required by the device. It also brings in any external object files for which you don't have the source code (or have already compiled it in a previous iteration).

This is generally referred to as a toolchain, but may be informally referred to as a compiler.

You'll also need a way to copy the .hex file onto the microcontroller. The usual way to do this is to use a programmer, though it is often convenient to program the device with a bootloader first, and then use this program to copy the .hex file in.

These are some of the most basic steps of embedded software development. You may find native programming a bit easier if you want a slower learning curve. Also, the AT89C51 (now the AT89S51) uses an older 8051 core, you may find more modern processors like the ATmega, PIC18, or (much more new, but more complex) ARM cores (Cortex-M3/M0, probably) to be more user-friendly and well-supported. Another way to learn embedded development is through the Arduino (AVR) system, but that gets you out of C and into a beginner language.

  • \$\begingroup\$ The better language is C++ ( with some quibbles ) \$\endgroup\$ Mar 1, 2011 at 20:43
  • 9
    \$\begingroup\$ @russ, that's a minority view, especially in small microcontrollers. I'm sure there's a relevant stackoverflow question... \$\endgroup\$
    – markrages
    Mar 2, 2011 at 1:03
  • \$\begingroup\$ The linker generally produces some proprietary binary file - for example my (rather old) version of the Keil toolchain produces a file with no extension. A separate step is to convert this to a text file which contains the code in one of several standard hexadecimal formats, eg IntelHex or Motorola S, which is recognisable by the device programmer. It is this file which usually has the .hex extension. Some development systems that support in-system-programming via bootloaders bypass this last step and load the binary image directly using a standard or proprietary interface. \$\endgroup\$
    – MikeJ-UK
    Mar 2, 2011 at 10:04
  • \$\begingroup\$ @Mark - I think Russ was referring to the version of Wiring (which is similar to C++) that the Arduino uses - I called it a 'beginner' language since it hides some of the details behind the Arduino framework, and I think he called it 'better'. Anyways, the relevant E&R question is here. \$\endgroup\$ Mar 2, 2011 at 13:52

In Keil--> you select Project Menu -->Option --> at the Output tab --> ticked "Create HEX file"


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.