How to burn an already mounted (in PCB) microcontroller?

Thread Starter

jkcobain

Joined Jun 8, 2014
40
Hello everyone,

I'm developing a project, which is going to need modifications in the future (adding outputs and stuff like that), so I would like to have a way to download a new hex file into de PIC (microchip) when it is already mounted in the PCB. I have no idea about how to do it. I have a programming device which works perfectly with the PIC itself, but when the PIC has other devices connected (resistors, LCD display, etc) it doesn't detect the PIC. (This is my device http://www.webelectro.com.mx/wp-con...vio-gratis-750401-MLM20313745518_062015-O.jpg )

Do you guys know how can that be done? Or maybe another method such as a SD memory or RS232... I'm lost! :(

Thank you in advance!!!
 

DickCappels

Joined Aug 21, 2008
10,153
If, after reading the tutorial that Papabravo provided, you realize that you are using some of the ICSP pins in a what that keeps them from working with the programmer (as I think you hinted in your post) you can consider swapping pins around within your application to free up those pins, using a controller with more I/O, or using jumpers to temporarily isolate the afflicted pins from the rest of the circuitry.
 

Picbuster

Joined Dec 2, 2013
1,047
Hello everyone,

I'm developing a project, which is going to need modifications in the future (adding outputs and stuff like that), so I would like to have a way to download a new hex file into de PIC (microchip) when it is already mounted in the PCB. I have no idea about how to do it. I have a programming device which works perfectly with the PIC itself, but when the PIC has other devices connected (resistors, LCD display, etc) it doesn't detect the PIC. (This is my device http://www.webelectro.com.mx/wp-con...vio-gratis-750401-MLM20313745518_062015-O.jpg )

Do you guys know how can that be done? Or maybe another method such as a SD memory or RS232... I'm lost! :(

Thank you in advance!!!
at first you have to use a boot loader like microchip's pic kit x
secondly you load a program, in the pic, allowing to prog it ( see microchip app lib not all pic will work with that appli).
But look first at your schematic do NOT put cap's direct onto the prog pins and mclr pin. Place always a resistor(>=1K) between Pic pin and cap.
see my previous reply and schematic's.
 

Picbuster

Joined Dec 2, 2013
1,047
If, after reading the tutorial that Papabravo provided, you realize that you are using some of the ICSP pins in a what that keeps them from working with the programmer (as I think you hinted in your post) you can consider swapping pins around within your application to free up those pins, using a controller with more I/O, or using jumpers to temporarily isolate the afflicted pins from the rest of the circuitry.
At a pic you can use the prog pin's for in or output ( provided that a 1K resistor feeds your circuitry and the progger is direct attached to the prog pins.) example pic 18f8722 pin 9 MCLR needed to prog but the loaded program could use this pin for in or output. (assuming that the status set to use pin digital.( disable pin for mclr function during application run).
same to prog pin's 47 and 52.
 

Thread Starter

jkcobain

Joined Jun 8, 2014
40
Ok, thank you a lot for your help, everyone! But please let me know whether I fully understood, or I'm missing something.

What I understood is: if I design my PIC code, in a way that I leave PGC and PGD pins free (or isolate them), and I isolate MCLR from PCB voltage source everytime I'm programming, then I should be able to program my PIC.

And what about Vdd and Vss? If I want to use the power of my PCB (instead of programmer's power, in order to make less wiring and isolations), should I make something (like a bridge between grounds or something like that) to provide the zero reference to the PIC of PCB and programmer voltages?
 

NorthGuy

Joined Jun 28, 2014
611
What I understood is: if I design my PIC code, in a way that I leave PGC and PGD pins free (or isolate them), and I isolate MCLR from PCB voltage source everytime I'm programming, then I should be able to program my PIC.
For most PICs, the code you program or have programmed on the PIC won't matter (although there are exception, especially among older PICs). What is important that you do not have anything connected to PGC and PGD pins, such as capacitors, loads, LEDs etc.

For MCLR, if you just put 10K resistor between MCLR and VDD, it'll be good for most PICs with nothing else required (but again, there are exceptions).

If you want to use PGC/PGD/MCLR somehow, it's all possible, but it's much easier if you can avoid it.

And what about Vdd and Vss? If I want to use the power of my PCB (instead of programmer's power, in order to make less wiring and isolations), should I make something (like a bridge between grounds or something like that) to provide the zero reference to the PIC of PCB and programmer voltages?
You should connect both VDD and VSS directly to the corresponding pins in the ICSP header. This will put the board ground and the programmer ground on the same level. Otherwise, it won't work. If it's impossible to do because they're already referenced to different voltage levels, you need whole lot more than simple resistors.
 

Thread Starter

jkcobain

Joined Jun 8, 2014
40
Thank you! I really appreciate your help!!

If it's impossible to do because they're already referenced to different voltage levels, you need whole lot more than simple resistors.
The problem is that my programmer won't have enough current to feed the whole board, so I'm assuming that it is not going to work because of the voltage drop. Do you think diodes can solve the problem?

(In this scenario I'm disabling the PCB's voltage)
 

jpanhalt

Joined Jan 18, 2008
11,087
Re: Power
I use MPLAB IDE, but others are similar. Click on the Programmer Tab>Settings>Power and you will get something like this:
upload_2016-3-8_0-33-25.png

Be sure the box is not checked. Now the target is powered by whatever you want it to be powered by. You still need the Vss and Vdd pins of the ICSP header attached. That header has 6 pins in Microchip factory devices. Only 5 of the pins are used. Auxillary pin is not used.

Re: Diodes
Generally not needed nor advisable on any pin except MCLR. For MCLR, Microchip often shows a diode for isolation and many people use one. Watch the orientation. However, on the Microchip forum you will find many posts advising against a diode and using only a 10-k to 20-k resistor for isolation from the target's supply. Vpp of course goes directly to the pin.

John
 

Thread Starter

jkcobain

Joined Jun 8, 2014
40
Re: Power
I use MPLAB IDE, but others are similar. Click on the Programmer Tab>Settings>Power and you will get something like this:
View attachment 102089

Be sure the box is not checked. Now the target is powered by whatever you want it to be powered by. You still need the Vss and Vdd pins of the ICSP header attached. That header has 6 pins in Microchip factory devices. Only 5 of the pins are used. Auxillary pin is not used.

Re: Diodes
Generally not needed nor advisable on any pin except MCLR. For MCLR, Microchip often shows a diode for isolation and many people use one. Watch the orientation. However, on the Microchip forum you will find many posts advising against a diode and using only a 10-k to 20-k resistor for isolation from the target's supply. Vpp of course goes directly to the pin.

John
I'm using an unofficial programmer, and it doesn't have the option to disable its power. About diodes, based on the answers I received before, I think I know what to do with MCLR, PGD and PGC. My only question is with the power. I'm thinking on three possibilities.

1. Connecting Vdd, and Vss to the PCB power (same voltage as programmer's. I'm unsure with this one because when I studied circuits, I never saw voltage sources connected on parallel, only series. and I don't know whether the programmer's Vdd could get damaged, regarding that it is an output an it would be connected to external voltage, as if it where an input)
2. Designing my PCB with diodes between PIC's Vdd, and my PCB's voltage source, and connect the programmer Vdd (and Vss) direct to the pin, so I avoid the programmer's voltage drop (while the PCB voltage source is off).
3. Same as 2, but using jumpers instead of diodes.

Which of the three should work? Or maybe none of them?

Thank you! and please excuse me for getting stuck on the same question :(
 

John P

Joined Oct 14, 2008
2,025
It may be something you "shouldn't" do, but I've never had any problem programming a PIC that was powered all the time via a separate power supply, i.e. not powered by the programmer. I just don't connect the programmer's Vdd line. I'd be careful to avoid tying two power sources together! Do it with diodes if you think it's necessary to have both.

One thing you can do to get some use out of the chip's PGC/PGD lines is to use them for pushbuttons, connected to Gnd. That's assuming you can be sure the switches won't be pressed during programming. The same applies to the Vpp pin if you have a chip that allows you to use it as an input, though it has no internal pullup and thus isn't as easy to use. Alternatively, there must be some value of resistance between the PGC/PGD lines and external components which wouldn't cause problems during programming, if you really have to use those pins for other purposes.
 
Last edited:

jpanhalt

Joined Jan 18, 2008
11,087
The default for the MCC programmers is not to power the target by the programmer (i.e., box not checked). Without knowing more about your programmer, one cannot say for sure whether isolation diodes are needed on Vdd. It is DC and connecting equal DC voltage sources in parallel is done all the time, like in batteries, but there are clear occasions when back-feeding a DC source can be bad, such as with many voltage regulators.

Rather than a diode, you might consider just a small resistor (say, 200 ohm = 25 mA @ 5V)) on Vdd between the board and your programmer. Then make sure the programmer is powered before powering the board and/or connecting a powered board to the ICSP header (assuming that 25 mA back-power might be bad). My ICD3 programmer needs to sense voltage on the target before it will program.

John
 

dannyf

Joined Sep 13, 2015
2,197
Which of the three should work? Or maybe none of them?
In general, you don't want to power the chip and associated circuitry from the programmer - it has limited current capability.

The data sheet and programming manual goes into great detail about what should be done for icp to work- generally you want to have some isolation resistors there.
 

NorthGuy

Joined Jun 28, 2014
611
The problem is that my programmer won't have enough current to feed the whole board, so I'm assuming that it is not going to work because of the voltage drop.
You don't need to power the device with the programmer (and in most cases you don't want to). You need, however, make sure that the programmer and the board have common ground by connecting board's VSS to the corresponding ICSP pin. Unless you have something unusual (e.g. your board is referenced directly to hot main wire), this is a perfectly safe thing to do. And this is absolutely necessary to make the programmer work. If you do have something unusual, please explain what it is.

You also need to connect VDD to the corresponding ICSP pin. This is not to power the board with the programmer, but to let the programmer detect when you board gets powered and measure the voltage level. Unless you tell it to, the programmer will not supply any power, and most likely will draw some little power (few mA) from the board.
 

ErnieM

Joined Apr 24, 2011
8,377
You are probably safe putting the board power and the programmer power "in parallel" since as active elements the one with the higher output voltage "wins." if that is the programmer and it is current limited then it just drops down to the boards voltage, if the board is higher the programmer just drops out.

However, to be super safe with an off brand programmer you can leave the Vdd pin from the programmer unconnected.
 

NorthGuy

Joined Jun 28, 2014
611
However, to be super safe with an off brand programmer you can leave the Vdd pin from the programmer unconnected.
Although some of the programmers will work, but PICKit3 and ICD3 (as well as any other programmer with built-in level shifters) won't work if you leave VDD pin of the ICSP header unconnected.

[edit] ... unless you configure them to provide power to the target, in which case they create their own (possibly wrong) voltage on VDD.
 
Last edited:

John P

Joined Oct 14, 2008
2,025
My PICkit 2 clone doesn't care if the Vdd line is connected or not. But one reason I usually do power my target system from the programmer is simply so that I only have to connect one cable. The simpler the better.
 
Last edited by a moderator:

Thread Starter

jkcobain

Joined Jun 8, 2014
40
Ok guys! thank you very much for your help. Some people say one thing, and some another xD. I guess I will need to find out the best way for my own programmer. Anyways, you already told me what I think is the most important (MCLR, PGD, PGC).

Thank you!!
 
Thread starter Similar threads Forum Replies Date
B General Electronics Chat 4
popping_circuts General Electronics Chat 1
koral Technical Repair 8
A Power Electronics 19
behrooz_chz Power Electronics 2
Top