Microchip PIC C18 Programming File Format .COFF vs .HEX

Tag: compiler , embedded , hex , microchip , coff Author: chonghui27 Date: 2010-07-20

I am developing code in the MPLAB IDE and I was wondering if it is better to program a chip using the .COFF or .HEX file generated by the compiler. I'm not sure what the difference is between the two and I am assuming they will both perform the same job.

Best Answer

A COFF will typically contain debugging information (line numbers, symbols, etc.) that is useful when running the code in the IDE. The .hex format just contains the program's binary data, and is what you'd typically use to program the microcontrollers for production.

IIRC, you debug a Microchip controller by burning the code to flash, then using the ICD to step through your code, set breakpoints, etc., so either COFF or HEX will suffice. But with COFF, you have the link back to the source code that will make the debugging process much, much easier.

Other Answer1

Either can be used to program the chip. The HEX file contains machine code. The COFF file contains the machine code as well but also carries information useful for debugging such as symbol names, line numbers, etc.

Other Answer2

It is better to program with COFF if using the IDE, and save the HEX for commits. Since the HEX file is ascii, it can be checked into source code control and diffed easily. With microchip PICs, it's easy (well.. yes) to verify fuse settings for example by checking the HEX file, so if different versions of the .asm or .c set fuses differently, a simple diff of HEX will reveal the change.

Other Answer3

COFF is binary (as far as I know), where as HEX is ASCII. Once the device is programmed, there is no difference (the binary contents of the PIC should be identical among the two). I think a lot of 3rd party programmers (devices) only support HEX-files, which therefore often is what I use.