PIC in circuit programming voltage - Page 1
Forum section: electronics / beginners

author: hinxx
author_rank: Contributor
timestamp: February 27, 2024, 01:20:09 pm
content: I have a circuit containing a PIC as seen below.Reading up on how to program the little guy in circuit (ICSP) I realized that MCLR pin is supposed to be pulled to +12V. I have access to it on a programmer connector on the PCB, as well as Vdd, GND, PGC and PGD (no PGM available). Vdd is +5v. There are other components that share the Vdd with the PIC.I'm concerned by just feeding +12V into the circuit.. or will it work ?

author: jpanhalt
author_rank: Super Contributor
timestamp: February 27, 2024, 01:56:05 pm
content: I am a little confused by your schematic. It doesn't show how you plan to connect the programmer.Having a resistor between the VPP and VCC pull-up is generally all that's needed for protection. Some older recommendation were more complex and included a diode (See: Capture) and capacitor to ground. Generally, I go to the datasheet for the chip I am using and follow its guidance. What that usually means is that a diode is not necessary and the capacitor can be deleted too (See:Capture2).

author: hinxx
author_rank: Contributor
timestamp: February 27, 2024, 02:09:27 pm
content: Thanks for clarifying the diode part! I've seen the first wiring in Microchip AN and got worried I'll fry the PIC/other stuff if there is no diode.> I am a little confused by your schematic. It doesn't show how you plan to connect the programmer.From programmer side: PGC/PGD connect to RB6/RB7, MCLK would be fed +12V, Vdd is +5V, and of coure GND to GND..So far I was not supplying the +12V to MCLK, but just +5V. I'm trying to use this programmerhttps://github.com/gphalkes/fpicprog, but I'm unable to read out the device ID, ie. identify the part prior to any other operations. Do I need the +12V on MCLK to be able to read out the PIC chip ID?

author: Andy Watson
author_rank: Super Contributor
timestamp: February 27, 2024, 02:24:08 pm
content: Quote from: hinxx on February 27, 2024, 02:09:27 pmYes. The 12V on MCLR puts the chip in a different mode. Also, although PGM is not used for "high voltage" programming, you might experience some problems if this pin is not pulled low - the PIC programmers have a 100k to ground - IIRC.

author: MrAl
author_rank: Super Contributor
timestamp: February 27, 2024, 02:31:22 pm
content: Quote from: hinxx on February 27, 2024, 01:20:09 pmHi,This may not apply to your part number, but not all PIC's are like that now. Some are programmed with a low voltage. I guess that means +5v but I have never used one of those low voltage types so far.

author: Ian.M
author_rank: Super Contributor
timestamp: February 27, 2024, 02:41:14 pm
content: It varies. Old FLASH PICs used 12.5V Vpp, then newer ones added optional low voltage programming with a PGM pin to enter that mode*and some reduced Vpp to (IIRC) 9.5V, then came along LVP only PICs (No Vpp>Vcc, no PGM pin) @ 5V Vcc and @ 3.3V Vcc.For 'fpicprog' to work with a HV programming only PIC, it would need a level shifter to drive Vpp with the appropriate programming voltage, under programmer control.* There were limitations - LVP could be disabled, which let the PGM pin (and optionally /MCLR) be used as I/O and you then couldn't reactivate LVP without a HV programmer.

author: jpanhalt
author_rank: Super Contributor
timestamp: February 27, 2024, 02:45:34 pm
content: @Andy Watson (I type very slow):Agreed. PIC's must be put in program mode. Originally that was done with a program (PGM) pin and/or high voltage on VPP. Current LVP devices are different:QuoteUnless your chip is specified for LVP, you have no choice. Note, the high voltage required to enter programming mode differs depending on the chip.What I was referring about programming was the isolation you plan to use for Data and Clock inputs. Microchip describes what is needed for those functions to work properly. If you have enough pins, it might be best to designate them as outputs and connect nothing to them. In program mode, they automatically become inputs, so you don't need to change that. If used as inputs, presumably adding a resistor to protect the rest of the circuit is sufficient. If used as outputs that need to source significant current, that might not be the best solution. Jumpers/switches might be considered.

author: hinxx
author_rank: Contributor
timestamp: February 27, 2024, 03:04:32 pm
content: Lot of answers, I type slow too. Thanks guys!First of all, I'm still little uneasy to connect +12V to MCLR given how my circuit looks like.Looking at the pics of @jpanhalt I see that the second case clearly has Vpp and Vdd separated. In my case MCLR is connected to VCC (through 10k resistor) rail and VCC which also connects to Vdd of the PIC on the PCB. Wouldn't that cause the +12V from programmer side, put on the MCLR, to reach VCC and therefore Vdd of PIC (and other chips on the PCB)?Looking at the first pic I can understand that the diode will prevent the +12V to creep into Vdd; and that is what my circuit is missing.> Yes. The 12V on MCLR puts the chip in a different mode.That explains why I'm not getting anything from the PIC so far..> Note, the high voltage required to enter programming mode differs depending on the chip.I checked:Voltage on MCLR with respect to VSS (Note 2) ......................................................................................... 0V to +13.25VThe chip is also LVP capable, if configured as such AFAICT. The microc compiler configuration file I received along side the device and HEX binary suggests that the LVP bit is cleared and therefore the chip is not in the mood to perform low voltage programming. The PGM pin on the circuit is being used as a normal I/O pin, further suggesting that the LVP is indeed not available (as per the text attached).> Microchip describes what is needed for those functions to work properly. If you have enough pins, it might be best to designate them as outputs and connect nothing to them.True. They are not used for anything else but ICSP.> If used as outputs that need to source significant current, that might not be the best solution. Jumpers/switches might be considered.Yeah, I do not have the option to tinker with the PCB, or I would at least like to avoid it if possible.> For 'fpicprog' to work with a HV programming only PIC, it would need a level shifter to drive Vpp with the appropriate programming voltage, under programmer control.Right. I read the readme saying that was required ; I'll need to look into that now that I know MCLR needs to be at +12V.

author: jpanhalt
author_rank: Super Contributor
timestamp: February 27, 2024, 03:26:12 pm
content: Quote from: hinxx on February 27, 2024, 03:04:32 pmThere have been many discussions about isolation of VPP from VCC on the Microchip forum. It's my impression that a 10k resistor is considered adequate. 12V at 10k = max of 1.2 mA. That's what I use. (Some chips have an even lower VPP.) You could probably use a higher value resistor without a problem. It's connection to VPP is simply a weak pull-up, which MCLR already has. That is, you cannot turn off the WPU on that pin.

author: hinxx
author_rank: Contributor
timestamp: February 27, 2024, 03:38:41 pm
content: Got it jpanhalt! Just wanted to double check. Going to give it a try..

author: mikerj
author_rank: Super Contributor
timestamp: February 27, 2024, 04:49:50 pm
content: Provided the rest of your circuit (including the ICSP programmer itself) sinks more than the current flowing through the 10k pull-up on the reset pin it will be fine (12-5/10k=700uA). I would expect this requirement to be met even with only the PIC being powered. You could prove this by gently ramping up the voltage on Vpp and monitoring the Vdd rail for any voltage rise.If you are still concerned this might not be the case you could add a 4k7 resistor between Vdd and 0v to sink ~1mA. Preferably add this to your programmers connector (or make a small interposer board) rather than on your circuit PCB unless you don't mind the additional permanent current draw.