Design Trick: Neat Tricks for using HEXMATE

Hexmate is a new utility which will be included with all future versions of the PIC® compilers (HI-TECH PICC, HI-TECH PICC-18 and HI-TECH C® for dsPIC®/PIC24). Essentially Hexmate is a tool for making modifications to the HEX file generated by the compiler. Hexmate has many tricks up its sleeves, but in this article we will focus on one handy feature - embedding serial numbers.

Often, when producing a product it is necessary for each one to be uniquely identifiable, ie: to have a serial number. Since each unit will have a different serial number, this means the program memory image will be different for each unit. This can be done a couple of different ways. For each unit, re-compile your application and change only the serial number (impractical), or, compile once then use some other tool to modify the program image for each unit.

This is where Hexmate can be of use. Hexmate will take your application hexfile, the serial number you wish to use, the address where you want the serial number to be stored and will generate a new hex file with this serial number embedded. Need more than one serial number? No problem, Hexmate can insert multiple serial numbers at selectable address intervals and even increment the number by a selectable amount.

Now if you just need to insert one simple number, then your chip programmer may already offer this feature. If you need something more complicated however, then Hexmate is probably up to the task. One example of this is when used with mid-range PICs. Typically on a mid-range PIC constant data is stored as a series of return (RETLW) instructions allowing only one byte per location. If you are using serial numbers greater than one byte, this will mean not only dividing your serial number into bytes, but also storing them as an instruction, a feature many chip programmers can't do but becomes trivial with Hexmate.

Inserting serial numbers is just one feature of Hexmate. Filling, replacing, searching and merging Hex files are all possible.

To find out more about Hexmate or to download a free copy, visit the Interesting Projects and Tutorials section of our On-line Forums.


 

September 2005.