There are 4 types of programmer; Serial,
Parallel, USB and Bootloader.
Here you can find essential information for choosing or building your own pic programming circuit.
The best way to program your PIC chips is to use a USB programmer and that communicates to your
hardware via a USB interface. These are reliable and easy to use (much easier
than serial or parallel port programmers).
All you really have to make sure is that it supports your devices and that you have an ICSP interface. The difference is that some programmers allow you to insert the PIC chip into an IC holder to program it and then take it out and place it in a circuit. Using ICSP means that you can leave the PIC chip in the circuit and still program it easily.
Suggested programmers are the pickit2 or pickit3.
You can build your own programmer if
you have an older computer with either a serial port or parallel port. (I
expect you could also attach a serial programmer - using RS232 - to a USB to
serial converter but I have not tried this at all.
You can also find information on ICSP, LVP and bootloading.
Is your programmer not working or showing random data on verify? If you are using long cables then its probably because the cable is behaving as a transmission line. If you don't know what this means then follow this link.
Important note: If you are using a laptop then don't use a pic programmer that is powered from the serial port itself as there may not be enough power/voltage available from it.
Here is an example of a parallel
I use the ICPROG programmer which is free software running on my spare computer (i.e. really old computer - running Windows95). Its actually quite useful and it saves blowing up a laptop!
You can find ICPROG here [opens new window].
A pic programmer is a circuit which interfaces the PC to the microcontroller using the PC's parallel,serial or USB port. It can write data to the microcontroller and read it back for verification.
The pic programmer translates digital logic levels from the PC to suitable logic levels for the microcontroller - most levels are ok as they are, but for 'normal' (or high volt) programming of a pic microcontroller the following voltage at the MCLR pin is needed:
source : PIC application note ICSP (DS30277)
Note: the maximum input voltage to the pin is (MCLR) 14V but on some newer PIC micros this is lowered to 13V so be careful of this specification.
The 13.5 volt level complicates the interface circuit since the voltages from the parallel port or USB port are not that high. Typical digital logic levels are nominally 5v so usually these programmers require use of an external power supply to generate the higher voltage.
The serial port generates higher voltages and this fact is used by programmers such as a JDM pic programmers.
To program older pic devices you need a high voltage programmer.
The programmer should isolate the microcontroller so you can test the microcontroller program while the programmer is still attached.
JDM 'type' serial port programmer details.
The JDM serial port pic programmer cleverly uses the serial port to provide a high voltage programmer that does not require an external power supply. Its cheap and easy to construct and is useful for programming one off chips but you have to insert and remove the chip that you are programming moving from the programmer to the development board.
Personally I don't like doing this as I just want to connect the programmer to my dev board, leave the chip in place, and get on with solving the task.
The problem with these programmers is that they reference the programmer's ground to the -ve serial output voltage. So the programmer's ground reference (to the PIC chip) is -8V (or whatever negative voltage the serial port generates). This is done to get a voltage swing of >13V that can be regulated by a zener to about 13V.
In practice this means that you can not make any ICSP connection to your development hardware as you can not connect development ground to -8V! so you have to remove and insert the chip.
I recommend that you use a pic programmer that needs a power block.
All pic programmers work the same way (except the bootloader - see later) - they generate a serial data stream using two signal lines clock and data. Another pin controls the programming voltage (at MCLR) and two others supply power and ground.
Another program running on the PC (the programming software) takes the hex file generated from your compiler translating it into a serial data stream. This is routed to your programmer through the correct interface (Serial,Parallel or USB). From there the programmer presents the signals to the microcontroller.
After all the data is sent, a serial configuration word is sent, and voila - the microcontroller is programmed ready for use.
Serial or Parallel programmers describe the PC interface used not the programming method - all pic microcontrollers are programmed serially. Serial programmers connect to the Serial port and Parallel programmers connect to the parallel port.
The signals used at the parallel port interface still generate serial data - this is why a parallel port programmer is no faster than a serial port programmer.
In fact the speed of programming is determined by the pic programming algorithm and is much slower than any of the PC interfaces. In general programming a Flash pic device is quite slow (16F877A 30 seconds).
Note: This also depends on the PC speed and the hardware capability -I tried using the 1GHz machine and the program cycle was much faster - but you need to have hardware that allows you to go fast.
Programming seems slow when you make minor code changes and want to see the result quickly but compare this to old style EPROMs - you used to remove the chip from the board and put it under a UV light for 30 minutes!
At university the eraser broke down so we put the EPROMS in the photocopier and photocopied for a while to erase!
A method called LVP (or Low Volt Programming) is available for newer PIC devices - as it suggests you don't need the higher voltage. The disadvantage is that you loose one pin which may be ok for larger 40 pin devices but probably not for 18 pin devices. It would depend on your circuit requirements. See discussion on LVP, for more information.
Note: You can only change from LVP to HVP (High Volt Programming - normal ICSP programmer) if you have an HVP programmer. The parts that are LVP capable are factory shipped with LVP enabled. So always pull the PGM line low with 10k (approx.) when first programming (with HVP).
There is one other way of programing a pic device and this is using a piece of software called a bootloader. This method is only usable on the newer devices that can re-program parts of their own FLASH memory - these days that is loads of them and it is now more common to expect this self-programming action rather than thinking of it as unusual e.g. 18F2550.
It is a small program that typically monitors the USART receive data line (RX) and activates itself if there is any activity on this line within a set time period after reset e.g. one second from power up.
When activated it accepts data from the Rx line using it to program the rest of the FLASH memory i.e. it does not overwrite itself. When all data has been loaded and programmed it starts up the new program or boots (starts up) and loads hence Bootloader.
Interestingly it is called a bootloader referring to a legend about Baron Münchhausen who was able to pull himself up by his boot straps; an impossible task. The process of booting (bootstrapping or starting a system) also seems like an impossible task if you ask the question how can I load and start my program if there is no program in the device to load and start my program!
The answer is that you use a simple piece of software to load the more complex one. This simple program then transfers control to the new program. In a PC this is the BIOS bootstrap code. For the PIC micro you program the bootloader code using a standard (high volt) pic programmer.
Since you need a normal pic programmer (or High Volt programmer) to get the bootloader into the microcontroller in the first place why bother with it?...
Answer 1: It is can be faster than serial programming using ICSP - depends on internal Flash programming speed.
Answer 2: You can load code into a fully built system - without using ICSP so there are no pins that need to be considered for Vpp, PGD or PGC - also a high volt programmer is not needed.
The bootloader lets you use any interface (depending on how you program the microcontroller) to load code. Its main use is infinished equipment where software updates are needed (without opening the box up and plugging in a pic programmer). Equipment that normally uses an RS232 port could be bootloaded through that port. All you would need is a serial cable and hyperterminal (available in Windows). Note other interfaces can be used e.g. I2C, SPI, Ethernet, Wifi etc.
Note: Bootloading is not limited to any specific interface - you could bootload over a network interface or an infrared IRDA interface.
This is a list of some of the programmers available as circuits that you can search for on the web.
The above list shows programmer types supported by
ICPROG [opens new window]
There are many more circuits! but - they all do more or less the same thing!
There are several elements to a programmer but the most important is the ICSP connection.
Possible programmer features...
Don't buy a Serial port powered programmer if you use a laptop as its output power may not be good enough to operate the programmer (laptops like to make power savings to save their batteries!).
Some also use only +/-5V outputs as this level is still within the RS232 standard (although it will not work over large distances). The minimum high and low voltage for receiving RS232 is +/- 3V (normally the transmitter generates +/- 12V). The manufacturers get away with this as most uses of RS232 are short distances on the desk. For a programmer it means there may not be enough voltage to create the 13V for the Vpp signal!
Note: If you want to program chips by removing them from the target board you will want a stand alone programmer. To save money you could buy one with a DIL socket - just make sure to remove the chip using a chip extractor and not your fingers and thumb otherwise you may end up using your thumb as a rather nice pin cushion - believe me it hurts. Perhaps the ZIF (Zero Insertion Force) socket is a better choice!
If you have not got a chip extractor then use a screwdriver - alternately lever up each end of the chip - don't just lever one end up as you will bend all the pins at the other end.
The single most important feature you need in a pic programmer is the pic ICSP connection.
This is a set of connections that let you program the pic microcontroller while it is in your circuit - there is no need to remove the chip just program it.
This is the most convenient way of developing a prototype (apart from bootloading - see earlier) as all of the hardware once connected is just left as it is on the bench i.e. no removing of chips between programmer and prototype.
You can also connect the ICSP wires to a solderless plug block breadboard so this is also quite an easy way to develop circuitry but be careful where the Vpp wire is placed (13V) - not all the pins can withstand this voltage so make sure it is at the MCLR pin.
If you buy a programmer with just ICSP then you can program most PIC devices.
Usual connections for ICSP:
For more details on ICSP click here.
To be honest I got fed up with the amount of circuits available as there are so many to look at and I also wanted something that was going to work. I decided to follow the one recommended by microchip themselves. It follows the AN589 application and gives you a programmer with an ICSP output connection.
Note: Not all the controls from the parallel port for this circuit are used by ICPROG - but this does not matter. It performs well if you add a transmission line terminator - a capacitor and resistor!.
See the following link for building your own parallel port programmer circuit including the transmission line terminator which allows it to work using a six foot parallel port cable.
You should use a USB based programmer either PicKit2 or PicKit3 as this is the easiest way to get started. These USB PIC Programmers are programmed using the software MPLAB X IDE (free).
Jump from PIC Programmer page
to Best Microcontroller Projects Home Page.
PIC PWM : What its for and how to use it. Including an example showing typical setup of a PIC PWM module with register settings.
How to use I2C. In this tutorial you will learn all about the 2 wire I2C serial protocol. Learn how easy it is to use, how it works and when to use it...
A 0-5V LCD volt meter project using an HD44870 display and one PIC micro ADC.
PIC programming : How to use ICSP for programming a PIC microcontroller giving some ICSP connection diagrams and it also shows how to use MPLAB X and ICPROG.
How to program PIC ICSP, IN-Circuit, live and still have a working programmer and operational circuit!
Understand how an Ultrasonic Distance meter works by building one your self – including Free software to drive the microcontroller and display.