Programming a PIC
Embedded programming is all about the mircocontroller. At the end of the project, it’s all about stepping back and allowing the device along with it’s supporing hardware and operate without human intervention.
Some applications enable the development to be simulated, however at some point the eventuality of downloading the compiled code onto your device is inevitable.The process of programming a PIC involves using an additional piece of hardware known as a programmer to export and and download the HEX file or compiled code onto the device.
Where to get a programmer?
There are a number of avenues that can be pursued to obtain a programmer:
- Hobbyisy Programmers
- Comercial Products
Do It Yourself
The DIY avenue has it’s place, not withstanding that is where most of us began. Personally, my first programmer was a parallel interface built off the WEB and used a Microchip application note for technical support.
DIY projects are widely available and easily found on the WEB. So a quick search will locate a suitable example.
Hobbyist Type Programmers
I am making a distinction bewteen DIY and hbbyist programmers on the basis that a hobbyist programmer is a non -comercial product which has aftersales service and backup. This type of programmer can be a worthwhile investment over time as new PICs are being released all the time. Since there is an organisation behind the product, continued support is more likely especiall when it comes to updating the device to support new PICs as they are released.
After my many attempts at DIY and other programmers. Microchip released the PICKIT2 and then later the PICKIT3. These programmers are ideally priced, they don’t need an external power supply and the use the USB interface to communicate between the PC and the target device.
The PICKIT 3 is the current iteration of the PICKIT 2 design and as a unit it’s compact and easy to use. I often take it with onsite so it’s entirely versatile.
As shown below, the PICKIT 3 intefaces directly with a PCB using the 6 way SIL ICSP header.
Figure 1: Pickit 3 and accompanying hardware.*
The PICKIT 3 can be used with MPLAB X or the standalone version of their software.
Commercial Programmers are generaly reserved for the professional developer or Embedded Design House and are designed to program devices en masse. These types are usually very expensive and unless as the developer you are deploying hundres of units at a time is overkill for the hobbyist.
Why a programmer is needed
A PIC is programmed using the ICSP or in circuit serial programming method which although is not overly complicated does require an “intelligent” collaboration between hardware and software to get the HEX file onto the PIC. This involves reading the device, erasing the memory, downloading the new code into the correct memory blocks and then jump starting the device once it is complete.
figure 2: Example hex file
When purchasing a development PCB, unless the Development PCB has an integrated programmer this additional piece of hardware will need to be purchased.
* Any images and products displayed here are displayed for information purposes only. The product branding and ownership of the product is retained by the product owners.