The Debug Capabilities of the PIC16F877
The PIC16F877 was the first Microchip Microcontroller to have in-built debugging capabilities. The actual silicon area used for the debug facilities is tiny compared to the major peripherals. Microchip initally kept the operation of the debug facilities pretty well under raps, but has recently released the specifications under DS51242A.
Making your own ICD
Fancy making your own ICD? I wouldnít imagine it would be any cheaper, considering the development time. Microchip has released the silk screen overlays and schematics for their ICD in Appendix A of the MPLAB ICD Users Guide (DS51184A). The code was suppose to be restricted, preventing you from making them. However d877.hex first appeared in the MPLAB 4.x directory. Upon closer examination of this file, you discover itís the source code for the ICD complete with embedded (retlw x-opcode) debug code which is loaded into the target at 0x1F00.
The code is for a PIC16F876 device which is the little brother of the 16F877. The PIC16F876 is a 28 pin device with a few less I/O ports, and the Parallel Slave Port. What this means, is you can use a PIC16F877 as the heart of the ICD if you are having difficulties sourcing the 16F876.
What Microchip hasnít released is the licensing information for the D877.HEX. Is it freely available for private and commercial use? Iíve already seen some making derivatives of the I CD for commercial gain. My guest would be that they are using the D877.hex in itís raw unaltered form, bearing in mind that dis-assembly is most cases is not legal either.
Revisions for the ICD
When Microchip released MPLAB v5.00 in March 2000, they shipped new firmware for the ICD, firmware version 2.04 (MPL876.HEX in your MPLAB 5 directory). This gave the end user support for the PIC16F873/874, supposedly better serial communications and the ability to perform flash upgrades over the wire with one mouse click.
They also released a Engineering Technical Note ETN#21, ďUpgrading MPLAB ICD Flash and Operating ICD below 4.5VĒ. This included two modifications, one for better support when operating the ICD from a supply voltage lower than 4.5V and the other to enable flash upgrades.
The first modification involved changing R21 and R22 which make up a voltage divider monitoring the VPP. These resistors were increased by a factor of 10 to reduce the load when low currents are available as a result of running the unit from under 4.5V.
Most of the early ICDís included OTP 16C73B. These of course cannot be updated over the wire, thus the second modification is to replace the 16C73 with a 16F876 which is pin to pin compatible, only in a re-programmable flash version. This enables to user to update the code at a later date.
Making your own modifications
http://icdprog.sourceforge.net - Linux Software which can program 16F87x devices using the ICD. Geir Thomassen has been examining the protocol between the ICD and MPLAB.References
John Andrews (email@example.com), John Day (firstname.lastname@example.org)
DS51242A On-Chip Debugger Specification, Microchip Technology Inc 2001.
PICmicro Firmware is copyrighted by Microchip Technology Inc., and is intended for Microchip Development Tools only. Modified firmware code will not be supported by Microchip Technology Inc.