On Sat, 9 Aug 1997 09:19:44 -0500 Fred Thompson writes: >Walter, > I have written a PIC programming program in C to work with a >home >made PIC programmer. The programmer I built is similar to several >described in magazines like Nuts & Volts, and Electronics Now. The >difference is that mine provides pins to set Vdd to the Max and Min >voltages for testing (the book said to do this when programming). >Most >kits don't provide for this, but I find it makes a difference (testing >at >Vdd Min (4.0V) shows if the chip has really been erased). My program >talks to the programmer through the parallel printer port. This would be very useful. > The program reads the *.COD file for the binary data to >program >the chip with. The binary data to program the chip with is also contained in the .HEX file, in a very simple format. For your programmer to be compatible with more software, it should (also) be able to use .HEX files which are supported by all PIC assemblers/compilers and used by all PIC programmers. There is no certainty that Microchip .COD files will match Hitech, will match CCS, etc. It also allows you to alter the data value at one >address >during program time, if you wish to include a "chip ID" which your >program >can read. (If you have several PICs on a serial line and you wish to >talk >to one of them you would send its ID. This programming feature allows >you >to vary that chip number at program time rather than re-assembling. If you're reading the .COD file, the programmer software would have access to the symbols, so one could define a special symbol and label a location with it, and the programmer would know to put the ID there. Using the hex file the user would need to enter the address of the ID location for the programmer. getid ;Read this chip's ID value to compare to address ; received over serial bus. ID returned in W. FT_CHIP_ID ;Special symbol for Fred Thompsom programmer retlw 0xff ;Programmer will patch actual ID here. On both 12 and 14-bit PICs, the retlw, movlw, xorlw, etc. instructions all store the literal in the low 8 bits. So the patch function of the programmer should leave the upper bits of the instruction at the ID location unchanged. >As I >understand it the PIC program can not read the chip ID numbers that >you >can program at the ID locations.) This is true. The ID locations can only be read when the chip is in programming mode. But it would be a good idea to store a copy of the ID value there so someone checking later could find it easily without needing to know where it is buried in the program.