In this Idea for Design, placing this circuit setup between the battery VDD bus and the PIC microcontroller allows you to execute in-circuit programming while protecting the application circuit.
Many PIC processors require 5-V power while being programmed, yet battery-powered systems may contain low-voltage devices that will be damaged at voltages above their maximum voltage ratings. In addition, application circuits may draw more current than the programming device can source, so unpowered circuits operating on 5 V may require isolation between the programming device and the application circuit. These situations require isolation of the application circuit (and the battery itself, in some cases) from the 5-V programming-device voltage used to power the PIC while programming it.
|Figure 1.||Adding this small circuit to a system using a PIC processor provides isolation of the
low-voltage loads from the 5-V programmer voltage, yet has minimal impact on the
normal operation of the system.
Placing the circuit of Figure 1 between the battery VDD bus and the PIC microprocessor will isolate the battery and the other circuitry from the 5-V power provided for the PIC from the programming device, such as an ME Labs U2 programmer. When the programming device is disconnected, Q1 is biased on by the 100-kΩ resistor from gate to ground while Q2 is biased off due to zero volts between gate and source.
During normal operation, Q1 provides a very low-resistance connection (65 mΩ) from the 3.3-V battery to the PIC. Q2 provides a low-resistance path from the programming device to the PIC power pins when programming.
While the programming device is connected to the system, Q1 is biased off by the 5-V source in the device while Q2 is biased on. This isolates the low-voltage analog and digital circuits in the target system from the potentially damaging 5-V being sourced by the programming device. Q2 will not turn on if the application circuit is powered from a 5-V source, but it will turn on if the power source is 3.3 V or less while programming the PIC.
Note that applications using 5 V must be powered-down while programming if using this circuit. Though the 100-kΩ resistor doesn’t load the battery, there’s a small loading effect on the programmer’s 5-V source. This effect is too small to be significant during programming.
|Figure 2.||The added isolation circuit requires only three components: Q1, Q2, and R1.|
The typical in-circuit serial programming application circuit is available at the Microchip Technology site.  In that design, the resistor between system’s VDD (battery-voltage levels) to the PIC VDD pins and ICSP connection will not provide good isolation from 5 V to the application circuitry. It also will not provide a low-resistance path from system VDD to the PIC, if the PIC is driving relatively high-current loads of tens of milliamps.
However, with this design, the programming voltage is completely isolated from the application circuit, while providing a low-resistance connection from the battery to the PIC during normal system operation (Fig. 2).