Author Topic: PIC in circuit programming voltage  (Read 500 times)

0 Members and 1 Guest are viewing this topic.

Offline hinxxTopic starter

  • Contributor
  • Posts: 12
  • Country: se
PIC in circuit programming voltage
« on: February 27, 2024, 01:20:09 pm »
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 ? :o
 

Offline jpanhalt

  • Super Contributor
  • ***
  • Posts: 3479
  • Country: us
Re: PIC in circuit programming voltage
« Reply #1 on: February 27, 2024, 01:56:05 pm »
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).
 

Offline hinxxTopic starter

  • Contributor
  • Posts: 12
  • Country: se
Re: PIC in circuit programming voltage
« Reply #2 on: February 27, 2024, 02:09:27 pm »
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 programmer https://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?
 

Offline Andy Watson

  • Super Contributor
  • ***
  • Posts: 2085
Re: PIC in circuit programming voltage
« Reply #3 on: February 27, 2024, 02:24:08 pm »
Do I need the +12V on MCLK to be able to read out the PIC chip ID?
Yes. 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.
 

Offline MrAl

  • Super Contributor
  • ***
  • Posts: 1440
Re: PIC in circuit programming voltage
« Reply #4 on: February 27, 2024, 02:31:22 pm »
I have a circuit containing a PIC as seen below.

(Attachment Link)

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 ? :o

Hi,

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.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12862
Re: PIC in circuit programming voltage
« Reply #5 on: February 27, 2024, 02:41:14 pm »
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.
« Last Edit: February 27, 2024, 02:46:42 pm by Ian.M »
 

Offline jpanhalt

  • Super Contributor
  • ***
  • Posts: 3479
  • Country: us
Re: PIC in circuit programming voltage
« Reply #6 on: February 27, 2024, 02:45:34 pm »
@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:
Quote
The Low-Voltage Programming Entry mode allows the PIC® Flash MCUs to be programmed using VDD only, without high voltage. When the LVP bit of Configuration Words is set to ‘1’, the low-voltage ICSP programming entry is enabled. To disable the Low-Voltage ICSP
mode, the LVP bit must be programmed to ‘0’.  Entry into the Low-Voltage Programming Entry mode requires the following steps:
1. MCLR is brought to VIL.
2. A 32-bit key sequence is presented on ICSPDAT, while clocking ICSPCLK.  Once the key sequence is complete, MCLR must be
held at VIL for as long as Program/Verify mode is to be maintained.

Unless 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. 
 

Offline hinxxTopic starter

  • Contributor
  • Posts: 12
  • Country: se
Re: PIC in circuit programming voltage
« Reply #7 on: February 27, 2024, 03:04:32 pm »
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.25V

The 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.

 

Offline jpanhalt

  • Super Contributor
  • ***
  • Posts: 3479
  • Country: us
Re: PIC in circuit programming voltage
« Reply #8 on: February 27, 2024, 03:26:12 pm »
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)? 

There 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.
 

Offline hinxxTopic starter

  • Contributor
  • Posts: 12
  • Country: se
Re: PIC in circuit programming voltage
« Reply #9 on: February 27, 2024, 03:38:41 pm »
Got it jpanhalt! Just wanted to double check. Going to give it a try..
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3240
  • Country: gb
Re: PIC in circuit programming voltage
« Reply #10 on: February 27, 2024, 04:49:50 pm »
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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf