This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Hex & Bin

Hi All,
What different about hex and bin file,
why the MUC that can be pragraming by these two format?

Thanks!

  • BIN is just plain binary format, no checksums etc.

    The Intel HEX format is described in the A51 manual (User's guide 02.2001) on page 394.

    The HEX file consists of lines that end on carriage return/line feed and the structure of them is always equal.
    :llaaaatt[dd... ]cc

    Every line starts with a ":"
    the aaaa is the address of were the date belongs to in a hexadezimal form.

    tt is the type field that specifies if it is a data record or an end-of-file record.

    ll is the length field that contains the number of bytes in the data field.

    dd.. is the data field, cc is a cheksum. Usually it contains between 0 and 16 bytes, more is uncommon. All fields are in a hexadezimal form and you can easily read a hex file with a text editor.

    What the processor receives as programming data (when it is programmed) is the decoded hex file. So it always receives "binary" data.

    If the processor programs itself while runtime (using a bootloader), then it could receive a hex file on the serial interface, decode it and check the checksum before writing the data to memory. But you have to write a bootloader that can "understand" the hex file format and that should usually send back an acknowledge or not acknowledge byte after every record.

    When you plug your processor into a programmer that "burns" the data into the processord memory, the data is written into that memory in a binary form using a certain programming algorithm, which describes the voltages applied and the timing. When the data is send to a bootloader program that runs on the processor, you can just specify your personal fomat and transmission protocol. So the format can be hex and binary and whatever you want (the bootloader ahs to decode it).

    Take care
    Sven

  • Well, Sven gave you a pretty good answer on the "What"

    why the MUC that can be pragraming by these two format?

    I assume that should be "MCU?" :-)

    Actually, the MCU doesn't inherently "know" about either of these file formats; nor, indeed, any other file formats - they are simply different ways of storing & transferring your executable code.

    If you TYPE a HEX file, or open it in Notepad, etc, you will be able to read it; it is in a text format;
    If you TYPE a BIN file, or open it in Notepad, etc, you will just see loads of "garbage;" it is a binary format.

    The reason for having the HEX format is that not all interfaces (especially RS232 interfaces, particularly in the old days) can transmit binary data; converting it to the HEX format gives a text representation which can be transferred!
    The HEX format also adds checksums, which help to detect any errors in the transfer.

    The HEX format was devised by Intel, so is sometimes known as "Intel Hex"
    Motorola devised their own format to address the same need - known as "S-Records"