Hi, it seems that a 'serializing' message of mine did not make it due to routing problems ;-) Here it is again: 1. To be able to use the serialization method, make sure that you select INHX16 code generation in the assembler (list directive). Do not use COD format. Use a batch file to run the programmer and the object file through it. I have never used MPLAB so I don't know but I STRONGLY prefer make for this sort of job (GNU or some other Unix make ported to DOS shell). 2. The exact format of the INHX16 file is described at www.wotsit.org and the number of Words need not be doubled in NN (you saw an INHX8M file probably which is an abominable format imho - it is confusing, ugly, and unjustifiable). Remember to compute the checksum on bytes, not words. For checksum purposes each DDDD is taken as DD + DD ... The sum including SS modulo 0x100 must be zero. ---------- Forwarded message ---------- Date: Wed, 14 Jun 2000 21:57:02 +0300 (IDT) From: "Peter L. Peres" To: pic microcontroller discussion list Subject: Re: Serializing >how it is done I can't give you the source, but here is a rational english outline of what is done: filenames: last_generated_file log_file numbers: last_code new_code strings: line start open last_generated_file // O_RDONLY if not error on open then read line from last_generated_file last_code = parse line if error parsing scream and die fi close last_generated_file else last_code = FIRST_CODE // hard coded value in program fi new_code = hash_somehow last_code // simplest is to increment open last_generated_file for write // O_CREAT | O_TRUNC | O_WRONLY if error opening then scream and die write new_code into last_generated_file on one line close last_generated_file open log_file for append or create // O_CREAT | O_APPEND | O_WRONLY if error opening then scream and die fi write new_code into log_file on one line close log_file write new_code as a single line hex (INHX16) record on stdout using proper encoding followed by a NEWLINE (in C), at address taken from arg1. end This is used in a DOS batch file like: date >temp_file copy log_file temp_file log_file :here prompt.bat // ask user to insert chip and punch key or ^C to exit serialh 0x80 >temp_file // this is the program above, compiled copy temp_file hex_file.hex hex_out.hex pgmdrv hex_out.hex // program the file goto here // forever Obviously there are no // comments in DOS batch files. It's been a while since I wrote something in DOS shell language so please check the syntax carefully. Some error check phases were omitted in the rational english description above. I remind that a INHX16 file record has the line (record structure): :NNAAAACCDDDD...SS where NN is the number of data (DDDD) WORDS (16 bits) in the line, AAAA the absolute address where the 1st word is placed, DDDD four hex digits expressing a 16-bit word, NN of them, and SS a checksum computed using the sum of all the bytes (not WORDS) in the record, including NN,AAAA,CC and all DDDD, like this: SS = (0x100 - (sum(as above) % 0x100)) % 0x100 where % is the modulo operator. Just in case. There should be a 0x13 at the end of the line. In C one prints '\n' and the compiler and OS library stubs manufacture the proper output for the OS used. In VB I don't know. Peter