Home > Electronic Tutorials > Microcontroller Tutorials > PIC 16F877A Project Tutorial > How to Program the PIC16F877A?

PIC16F877A Microcontroller Project Tutorial

How to Program the PIC16F877A?

I omit step by step details of how to program the PIC because software always changes.

As of spring 2010, the club uses software from CCS (http://www.ccsinfo.com/). 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 your project file.

You need to connect the ICD’s Ethernet cable pins to the appropriate pins on the PIC in order to load a program. You also need to have the PIC running (i.e. under +5V power) when programming.
See “How do I connect the CCS ICD to my own hardware?” in the CCS FAQ, http://www.ccsinfo.com/faq.php?page=icd_connection.

Don Crouse, the 2010 president, made custom programming boards to do that. They might still be in the lab. You can also cut up the wires on an Ethernet cable & connect them to the appropriate pins on the breadboard. If you don’t want to make your own device, you can buy what you need to program the PIC.

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 your own, is to select the family of the PIC. For the 16f877A, you 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 your 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.

Note: 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.
Note: To report broken links or to submit your projects please send email to Webmaster