Tuesday 24 July 2012

12th Day - 20 July Friday


HOW TO PROGRAM THE PIC ?


We use the PCW Compiler to write & compile programs and CCS Load and the ICD-U40 programmer to write programs to the PIC. Always load a .hex file onto the PIC – the compiled machine language program. The hex file should be located in the same folder as our project file. We need to connect the ICD’s Ethernet cable pins to the appropriate pins on the PIC in order to load a program.  We also need to have the PIC running (i.e. under +5V power) when programming.

Another available programmer the club most likely had is the PicKit 2.  To program with a PicKit, connect the pin marked by the arrow on the PicKit device to the mclr pin.  Pin 2 (next to the arrow) is +5, Pin 3 is Gnd, Pin 4 is B7, Pin 5 is B6, and Pin 6 is the optional debug pin PGM (not necessary to connect).  Also, connect the PIC to power & ground (the Vdd/Vss pins). To program a PIC, connect the PIC IC to the PicKit, and a usb mini cable from the PicKit to the computer.  To use the PicKit, run the PicKit V2 program on the desktop of the PC.  The first necessary step, if the PicKit is configured to program a different pic than our own, is to select the family of the PIC. 

For the 16f877A, we must select "base device" in the device options.  In order to program a hex file, it must be loaded / imported first.  Do this by going to file and importing our program's hex file.  After the file is loaded, click on the "write hex" button. This should write your hex file and say it programmed successfully.  The program will automatically start running even with the PicKit connected unless the /MCLR checkbox is selected. The PicKit has the capability to supply power to the pic via the USB bus.  It will automatically detect if the device is powered when trying to program.  If you want to run your PIC just from the USB, you can select the "Vdd On" checkbox.  This can supply up to 1A of current at 5V.  Make sure the voltage number next to the checkbox is set to 5 – unless your processor does not support 5V.  The PIC used in this tutorial is a 5v device.

No comments:

Post a Comment