Lego-Knex
Robbert
Mattijs
PIC programmer (software) V1.2
Stef Mientki
27-10-2001
Hardware

Program History
Downloads


 
File Commands Tools Help   Misc.
Open
Save
Exit
Read Device
Read ID
Verify Device
Write Device
Erase Device
Settings
PIC Definitions
Help
 

Run

  Program Start
Data Memo's
Device dependancy
Protocols
F84 <> F84A
Hex File

Operating Instructions 
It's important to follow the steps described below in the right order, because applying a voltage to the programmer pin of the PIC, without the PIC is supplied from a +5Volt source, can damage the PIC.

  1. start the program and select the right RS232 port (this will ensure that the voltage on the programmer will be ok) The voltages generated by the circuit can be tested before inserting a PIC, see here)
  2. set the switch on the programmer in the run mode (this will ensure that the program voltage will not be present until the +5Volt is present)
  3. now connect the programmer to the selected RS232 port
  4. now you can savely put the switch on the programmer in program mode
Data Memo's 
The topline contains the filename or the devicename, depending on where the last data was read from.
 
 
 
 
 

The large memo is the program memory.
If a complete row is empty ($3FFF) the row is not displayed.
 
 
 
 
 
 
 

The line with address $2000 are the ID words and other fuses. From version 1.2 these values can be edited.
 
 

The bytes, starting at address $2100 are the EEPROM data bytes. From version 1.2 these values can be edited.

Program start 
On opening of the program, all settings are read form the inifile ("applicationnam.ini") and the last hexfile is automatically loaded.
The program can be started automatically from another program (i.e. JAL-IDE), in which case parameters can be passed through the command line:

mind_picprog.exe   d:\data_test\aap.hex   PIC16F84   program
The first parameter is the name of the hexfile (including full path) to be used to program the device.
The second parameter is the devicename (including or excluding the prefix "PIC", so valid are "16F84" ,  "PIC16F84" ).
The third parameter is the command, only "program" at the moment. Command program will start programming the PIC immediatly, and if succesfull an outputfile with the contents "ok" will be produced and the program will automatically stop. If not succesfull, this outputfile will not be created and the program is not stopped. So the user can try to program the device by handcraft, if succesfull, the output file will still be created.
The name of the outputfile is the name of this programfile, but with the extension "out".
 

File Open 
Opens a hex file for reading. After openning the file, all the data is put in the corresponding memo fields.
The hex file must be a INXH8M file format, see below for details. The file may contain program data, config data and EEprom data data.
 

File Save 
Saves all information (program, config and data) on the screen in a INXH8M file format.
 

Exit 
Closes the program, after storing all settings in the inifile.
 

Command Read Device 
Reads program, data (eprom) and configuration memory and places the contents in the corresponding memofields.
If in the program memory a complete row is empty ($3FFF), then this row is not displayed. Config and data values are always shown.
The configuration memory ($2000 .. $2007) is both displayed in the corresponding memo and in the corresponding edit- and check-boxes.
The device-ID is checked against the selected device, and if a difference is encountered, a message is placed in the history memo.
 

Command Read Device-ID 
Reads only the Device-ID and puts it (only) in the corresponding edit-box.
The device-ID is checked against the selected device, and if a difference is encountered, a message is placed in the history memo.
 

Command Write Device
Writes program, data and configuration memory.
If no device is specified or if the device-ID differs from the selected device, no writing is performed and an error message is displayed.
Verifying of the data can be done during programming and/or after programming (controled by Tools / Settings / ...).
If verifying is done during programming, each word is checked and if an error is found the programmer retries a number of times (can be set by Tools / Settings / Nr. of retries). If, after the maximum number of retries, still an error occurs, the programming is aborted. After programming is done the programmer displays the total number of retries.
So a good setting is:

+ Verify during programming
- Verify after programming (there's absolutly no need for}
Number of retries = 3
Writing the device is time-optimized. First the first words of the device are compared to the words in the buffer, if there are differences a "bulk-erase" is performed, otherwise no "bulk-erase" is performed. After that, each word is only programmed if the word in the device and the word in the buffer are different. So if a device is programmed twice, no programming at all will take place the second time, only a device read.

Writing is device dependant, see device dependant settings.
 

Command Verify Device
If more than 20 errors are encountered, the program is aborted and an error message is displayed.
The device-ID is checked against the selected device, and if a difference is encountered, a message is placed in the history memo.
 

Command Erase Device 
Erases all, i.e. program, data and fuses.
After an erase cycle, there's no automatic verify cycle.
Erasing is device dependant, see device dependant settings.
 

RUN command 
With the RUN command (ok it's a strange symbol for that), you're first prompted to set the switch on the programmer to "RUN" after which the MCLR-line of the PIC is controled by the DTR-signal. Pushing on the RUN button will start the PIC by pulling the MCLR line high.
Pressing the RUN button again, will reset the PIC , prompt the user to set the programmer switch back to "Program" and enter the program/verify mode again.
 
 
 
Tools, Settings 

Verifying during and / or after programming can be selected individually. Normally you'll only choose for "during" because this will cost no extra time and above you can have retries. There's no need for verifying afterwards.

The helppath is the path, where this file is stored (normally the program directory).

Datapath is the path where your hex files are normally stored. If you read a hex file from a diferent directory, this path will automatically be addapted.

Clicking on the commport lets you select an RS232 port.

All settings are stored in the inifile ((applicationname.ini").


 
 
 
Test Hardware 

After a valid commport is selected, you can connect the RS232 port by checking the according checkbox.

To be compatible with different hardware configurations, you check which of the lines DTR/RTS should be used as dataline / clockline.
Also you can check which return-lines CTS/DSR should be used for data/clock.

When the RS232 port is connected, the input lines CTS and DSR are polled about 5 times per second and the status of these lines is reflected in the red/green panels.

By pressing "send $FF", 1000 times $FF is sent, resulting in a period of about 8 seconds of active signal on the TxD line.
If at the start of send $FF, both DTR and RTS are high, DTR is made low, this is done to prevent a program voltage occurs without the presence of the +5Volt supply.

The voltage should be measured with an appropriate load between +5Volt and ground.
    1 kOhm  --> 5 mA  (will do for the new devices, i.e. 16F84A)
    500 Ohm  --> 10 mA  (necessary for old devices, i.e. 16F84)

The voltages I measured where:
    Vdd = 5.0 Volt, which dropped 50 mV with 1 KOhm load
    Vpp = 12.5 Volt

Help 
Shows this help text in your own default browser.
 

Device dependant settings 
 
 
PIC definitions 

    Tools / PIC Definitions / ...

ID stands for the device-ID.
ID-mask are the bits that take active part in the device-ID (the newer types, some bits are used for the revision number)
ProgSize and DataSize speaks for themself.
Protocol, see below.
WriteCycle is the maximum value in milli-seconds of the write- / erase-cycle.

You can add new devices just by walking with the cursor to the bottom of the table (or by pressing button "Add New").

Numbers be inserted decimal or hexa-decimal (with a preceeding '$' sign).

Enter-key can be used to step through the fields of the table.

Protocol 1,2 
Before writing the device, always an erase is performed, with an explicit disabling of the codeprotection. In this way protocol 1 and protocol 2 could be mad almost equal. The only difference is the extra erase of the data-segment in the case of protocol 2.
Below you see the codes that are used in the program.
Read Device + Verify Read ID Write Erase
generate Vpp

Prog:
    $04 + getdata
    $06
    go Prog until ready

Data:
    $05 + getdata
    $06
    go Data until ready

    $00 + dummydata
Config:
    $04 + getdata
    $06
    goto Config until ready

Vpp down

generate Vpp

    $00 + dummydata
    $06
    $06
    $06
    $06
    $06
    $06
    $04 + getdata

Vpp down
 

ERASE (see next column)

generate Vpp

Prog:
    $04 + getdata
    if not already ok
        $02 + putdata
        $08
        delay(writecycle)
        $04 + getdata 
        in case of errors here
        retries are entered 
    $06
    go Prog until ready

Data:
    $05 + getdata
    if not already ok
        $03 + putdata
        $08
        delay(writecycle)
        $05 + getdata 
        in case of errors here
        retries are entered 
    $06
    go Data until ready

Config:
    $00 + getdata
    if not already ok
        $02 + putdata
        $08
        delay(writecycle)
        $04 + getdata 
        in case of errors here
        retries are entered 
    $06
    go Config until ready

Vpp down

Generate Vpp

    $00+$1FFF80

for 1 to 7 do 
    $06

    $01
    $07
    $08
    delay(writecycle)
    $01
    $07


This part only yields for protocol 2, "erase datasegment"
    $03 + $1FFF80
    $01
    $07
    $08
    delay(writecycle)
    $01
    $07

Vpp down


 

Write / Erase cycle time

16F84 = 20 msec (see note 1)
16F84A = 10 msec (specification is 8 msec maximum)
note1: Microchip isn't clear about this parameter, the official datasheet only specifies a typical value of 10 msec, no maximum value is specified. In the migration document 16F84 ==> 16F84A, a maximum value of 20 msec is specified for the 16F84. But from my own experiments I conclude that this is too low for a reliable programming of the device (even with retries).
  
Question 
What is the erase/cycle time of 16F84 ?
I'm developing a prototype programmer and miss the specification for the erase/write cycletime of the 16F84-10.  Your datasheet DS 30430C only specifies a "typical" value
of 10 msec. In the migration document DS 30072A you specify a maximum value of 20 msec. So I first designed the programmer with a erase/write cycletime of 20 msec, the results were totally unpredictable, sometimes it worked sometimes it didn't. After increasing the erase/write cycle time to 50 msec, programming errors didn't occure anymore.
Answer from Microchip 
The erase write cycle time is the same for all parts as they all use the same die. The difference between parts lies in how
they are tested. The erase/write times are a function of the die itself rather than the testing process. The data sheet has a footnote which explains that the erase/write times are characterised but not tested i.e we have designed the device to operate within these parameters but we do not test for this since it is not a critical operating parameter. Therefore it is possible
for the timing to be slightly greater than the design maximum on this parameter. To gain an avarage you may wish to program a larger set of parts from the same and different batches to determine a statistical average for the devices and then adjust your programming time c/w a margin of error to suit the average. 

Best Regards, UK Techhelp
THIS TRANSMITTAL AND ACCOMPANYING DOCUMENTS ARE INTENDED ONLY AS SUGGESTION.
No representation or warranty is given and no liability is assumed by Microchip Technology Inc. with respect to accuracy or use of such information, or infringement of patents arising from such use or otherwise. Microchip Technology Inc. recommends that you test all suggestions for suitability in your application.

Write protocol is different, see program source.
 

Differences between 16F84 en 16F84A 
The A-type has a maximum oscillator frequency of 20 MHz (instead of 10 MHz).
There are some small timing differences, of which the most important seems to be: MCLR low puls width, erase/program cycle time.
For simple programmers, which dereive their supply power from the RS232 lines, their is one other difference, although the specified maximum supply current during programming is 10 mA, the specified typical value is for the 16F84 is more then twice as high as for the 16F84A. See for further details  PIC16F84 to PIC16F84A Migration. Remark: the mentioned write/erase-cycle time of the PIC16F84 is not correct (see above).
 

Hex file format 
INHX8M, this format produces one 8-bit hex file with a low byte, high byte combination. Since each address can only contain 8 bits in this format, all addresses are doubled. This file format is useful for transferring PICmicro MCU series code to PRO MATE II, PICSTART Plus and third party PICmicro MCU programmers.
Each data record begins with a 9 character prefix and ends with a 2-character checksum. Each record has the following format:

:BBAAAATTHHHH....HHHCC

where:
BB - is a two digit hexadecimal byte count representing the number of data bytes that will appear on the line.
AAAA - is a four digit hexadecimal address representing the starting address of the data record.
TT - is a two digit record type record type that will always be '00' except for the end-of-file record, which will be '01'.
HH - is a two digit hexadecimal data byte, presented in low-byte/high-byte combinations.
CC - is a two digit hexadecimal checksum that is the two's complement of the sum of all preceding bytes in the record.
 

Program History 
ideas for V1.4
  • edit program area, what for ?
V1.3
8-11-2001
  • User can set which line (DTR / RTS) is used for data / clock
  • User can set how the return lines (DSR / CTS) are connected
  • Bug in verifying device-ID fixed
V1.2
27-10-2001
  • Only comport 2 could be selected, bug fixed
  • Test window added, so you can easily test & measure the voltage generated by the circuit
  • Command read device-ID didn't work well, bug fixed
  • Toolbuttons added
  • Commandline parameters added, so the programmer can be started from another program (i.e. JAL-IDE)
  • After reading a PIC, the oscillator settings were not displayed correct, bug fixed
  • Some report that the first program command didn't work, starting a second program command did word,  I'll hope this strange problem is solved (both timing and algoritmen are improved)
  • All PIC info is stored in an file, so you can add your own PIC if it isn't there through Tools / Pic Definitions / ..
  • Progsize + datasize is not fixed anymore but read from PIC info in ini-file
  • Button added, to reset the PIC if it's switched to RUN-mode
  • Timing is improved by holding DTR high (hold +13Volt) inbetween commands
  • Device-ID is now derived with a ID-mask, so a better comparison can be made
  • Programming didn't wait untill $FF were all send, this was unreliable, bug fixed
  • CodeProtection checkbox is removed, because the differences between the devices are to large (should be done by the hexfile) In the future probably all the other checkboxes, including oscillator settings will be removed, because also these parameters should be set by the hex file.
  • All those redundancies, form the former point, already removed, the line at address $2000 now can be edited instead
  • Edit data area, (but what for ?)
  • Fast programming (100 bytes in less tahn 3 seconds): disable read device-ID, disable bulkerase, stop if 20* $3FFF
  • Fast switching between program/run
September 2001, V1.1 Erase/write cycle time of 16F84A + unknown changed from 10 to 50 msecS
September 2001, V1.0 First release, with explicit facilities for 16F84 and 16F84A

Downloads 
Mind_PicProgV1_3.exe (  ) Selfextracting zip-file, containing executable program and help files
Mind_PicProgV1_1.exe (315kB) Selfextracting zip-file, containing executable program and help files
Mind_PicProgrammer_sources.zip
(122 kB)
Containing all sources of the latest version, including
  • comdrv32, component, encapsulation of the serial commport driver from Marco Cocco
  • texecfile, component to lauch applications by Kevin Savko