Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

ICSP considerations

Status
Not open for further replies.

MrDEB

Well-Known Member
In another thread the discussion of connecting to portB6 and B7 via a 10K pull-up resistor connected to Vcc was discussed.
I am working on a small project that HAD the pull-up resistor and when attempting to program kept getting a vcc voltage error.
This doc explains it clearly about connecting to port B6 & B7
https://ww1.microchip.com/downloads/en/DeviceDoc/31028a.pdf
this might save someone from same mistake as I made. See page 4
 
I don't think a 10k pullup resistor was your problem. I do that all the time without any trouble at all...well, at least with a (real deal) PICkit programmer. Thanks for sharing the article - good tips there.

To program a PIC, the programmer must be able to change the state of the PRGD (data pin) and PRGC (clock pin). Anything connected to these pins that prevents this from happening will cause issues. The programmer needs to have enough drive to counter any pullup or pull down resistors connected (PICkit will hand 10k resistors) so low value resistors will be an issue. Large capacitive loads will cause problems because they round off square wave signals. LEDs not connected with current-limiting resistors will be a problem too, as they clamp the maximum voltage to Vf of the LED.

A sure-fire way to screw things up are closed switches across the programming pins. In this case, you'll see DEVICE NOT FOUND errors because the programmer can't talk to the chip.

I was recently using a the PICkit 2's logic analyzer connected to the ICSP connector to toggle Port B pins for testing. PICkit 2 Logic Tool Trap and the following comments tell my tale of woe.

MrDEB, I suspect your 10k resistor was actually some lower value - much lower. The only time I've seen Vcc errors reported by a PICkit 2, there were power supply issues, like being shorted to ground through a low value resistor. Another error I've seen is "CAN'T CONTROL Vpp." This means the PICkit can't change the voltage on /MCLR. When I've had this happen, /MCLR was shorted to +5. I don't believe the PICkit 2 will give you Vcc errors for PRGC and PRGD - I don't think it measures the voltage on those pins. Either programming will fail or the device won't be recognized depending on the type of fault.
 
Using a Pickit 2 programmer.
The sheet from Microchip says that B6 and B7/
To simplify this interface the optimal usage of these I/O in the application are (in order):
1. Do not use RB6/RB7 so they are dedicated to ICSP.
2. Use these pins as outputs with minimal loading on signal line.
3. Isolation circuitry so that these signals can be driven to the ICSP specifications.
When you have a 10K pull-up connected to Vcc you are essentially applying Vcc to B6 and/or B7.
All I am sure of is I had a 10K pull-up and I could not program the chip. I clipped the resistor off and connected to some other pin.. Programming went as planned.
 
Yes, I agree with everything the app note says, and even most of what you say. However, I know 10k pullup resistors on B6 and B7 will not cause a problem when used with a real PICkit 2. How can I be certain of this? Because I have done it. Numerous times.

The picture below shows a 10k x 9 SIP resistor soldered across port B. The common pin is connected to +5. If you look closely, you'll see the 2nd pin is clipped off. Pin 2 is ground.

The second picture shows the top side of this board working. This board has been programmed hundreds of times over the last month. 4 more identical boards have been programmed many times over the last 2 weeks.

Your advice is good. Your conclusion on why you had problems is erroneous. It wouldn't be the first time your circuit isn't quite what you thought it was.

Why do I care? I could give a rat's ass about your problem (I'm glad you resolved it) but I don't like spreading misinformation about something that isn't an issue. Avoid using ICSP pins if you can. If you can't, don't load them too heavily - they will work fine.

20170105_141830.jpg

20170124_094130.jpg
 
The PICkit 2 schematic shows there is a 100 ohm resistor in series with the lines to the programming pins and a 5k pulldown to ground.

When the programmer output is high, effectively there is 100 ohms in parallel with 10k pulling high, and 5k pulling low. This is equivalent to a voltage divider with 99 ohms connected to +5 and 5k connected to ground. The output voltage when the pin is high will be 4.9 volts.

When the programmer pin is low, the equivalent voltage divider has 10k connected to +5 and 98 ohms to ground. The output voltage from the voltage divider will be 0.049 volts.

Not even close to causing a problem. The weak internal pullups are equivalent to about a 100k pullup resistor as I recall? That changes the above calculations....not at all.

10k pullups are safe on port B with a wide margin of safety. You need to look for another can of your problems MrDEB. physics proves you wrong in this case.
 
Clarifying, the output circuit looks like this. A 100 ohm resistor is in series with the PICkit output pin, and a 5k resistor pulls down to ground.
output circuit.jpg


When the output is high, the circuit looks like this. A voltage divider is form with the 100 ohm and pullup resistor are connected to +5, with the 5k resistor connected to ground. If the pullup resistor is 10k, the output voltage when the signal is high is 4.9 volts with a 5 volt supply. Any lower value resistor will move the output closer to +5 so the high level output is not a problem.

High Output Eqivalent Circuit.jpg


When the output is low, the circuit looks like this. The pullup resistor is the top part of the voltage divider. The lower part of the voltage divider is the 100 ohm resistor in parallel with the 5k resistor. The equivalent resistance is 98 ohms. If the pullup resistor is 10k, the output is 0.049 volts.

Low Output Equivalent Circuit.jpg


If the value of the pullup resistor is lowered, the output voltage will be increased. With a 5v supply voltage, anything level than 0.75 volts is low. You'fe have to go far lower than a 10k pullup to have a problem meeting requirements for high and low signal thresholds.
 
There shouldn't be any pull-up resistors on B6 and B7 (if you're talking about PIC18). The pull-up resistor goes to MCLR - E3. It is needed to keep MCLR high when the programmer is disconnected. You can also install a delay circuit on MCLR, but this is a different story.

PICkit3 (I guess PICkit2 too) has 4.7K pull-down resistors on B6 and B7. The reason for this is to make sure these lines are low when they're not driven (tri-stated by both PIC and the programmer), which happens quite often. If you put pull-up resistors on them, this will pull them somewhere to the mid-voltage when they're not driven. So, it most likely will not work. The best way to connect B6 and B7 is a straight wire/trace without any resistors (or anything else).
 
North guy,

Thanks for your input. We are specifically talking about pullup resistors on PRGC and PRGD and whether such resistors interfere with programming when using ICSP.

As I explained earlier, I can categorically say it is not an issue, at least with 10k pullups and a PICkit 2. I have done this before, including several hundred times over the last month without failure.

With a 5 volts supply and a 10k pullup, the resting state of the pin will be 1.67 volts. 2 volts or less is required for a low input.
 
MrDEB had a problem using pullups for momentary switches, and erroneously concluded that this could never be done.

In my case, I'm using Port B to monitor 8 digital signals. I assure you, programming with 10k pullup resistors is not a problem.
 
I re configured my port layout and put the Leds on portB.0-B.7
pull up resistors on portC.0 - C,7
Then using a for next loop I croped my code considerably. Posted code has yet to be run so it might hang up??
need to trisC & B the ports as outputs / inputs.
Still want to investigate Mikes suggestion about using a 16 bit variable but this posted code looks pretty slim and trim IMO

DEVICE = 18f2420
CLOCK = 8
INCLUDE"InternalOscillator.bas"
INCLUDE "SetDigitalIO.bas"
CONFIG MCLRE = OFF

DIM x AS BYTE
DIM swt(7) AS BYTE
DIM leds(7) AS BYTE
PORTC = %11111111 //ALL PORTC ARE HIGH
pORTB = %00000000 // ALL LEDS ARE OFF
WHILE true
FOR x = 0 TO 7
IF portB.bits(x)=0 AND portc.bits(x)=0 // BUTTON PRESS PORTC ARE SWITCHES
THEN //PORTB ARE LEDS
leds(x) = 1 //TURN OB LED
DELAYMS(200) //SWITCH DEBOUNCE
END IF

IF portB.bits(x)=0 AND portc.bits(x)=1 //SECOND BUTTON PRESS CHECK IF LED IS ON
THEN
DELAYMS(200)
leds(x) = 0 //TURN OFF LED ON SECOND BUTTON PRESS
END IF
NEXT
WEND
 
MrDEB had a problem using pullups for momentary switches, and erroneously concluded that this could never be done.

In my case, I'm using Port B to monitor 8 digital signals. I assure you, programming with 10k pullup resistors is not a problem.

For the momentary switches, it is better to use 10K pull-downs instead of pull-ups, and make the switches connect them to VDD. This way you won't need to remove the programmer when you run and test the PIC.

You may be able to do this with signals too, depending on the origin of the signals. However, if something drives these signals all the time then you need to disconnect this driver during programming and then disconnect the programmer during normal operations. This would be a disaster for me :)
 
The programmer will not be connected to the monitor while the monitor is connected to the device under test. Fortunately, the monitored signals are buffered, so nothing disastrous would happen but I would get erroneous results.

I am extremely concerned about interfering with the device under test. That's why the monitor's USB interface is optically isolated. I don't want to risk a ground loop or something taking the DUT offline!
 
Last edited:
Maybe an issue with circuit description. Here is basically what I had when I incurred a programming error using a pickit2
hopefully clarify what I did. IMO it is applying 5+ to the portB6
 

Attachments

  • icsp connections.jpg
    icsp connections.jpg
    231.4 KB · Views: 258
That is what a pullup resistor looks like. This did not cause your error.
 
That now has me wondering WHY when I removed the pull up the error does not come up.
Question is applying the pull-up are you not applying 5v to portb6
Having isolated ANY pull ups from portB6 & 7 this is now history. Read long ago try not to use B6 or 7 as per Blueroom and the pic programmer that I used to use. Time to move on but it bothers me why the error??
 
MRDEB, you have a history of what you think you have not matching the reality of what's really connected where.

As I have explained, demonstrated and mathematically proven, a 10k pullup resistor will not interfere with ICSP.

Also, I am fairly certain that nothing you do to PRGC or PRGD will cause a "Vcc error" to be reported by the PICkit GUI. The indication of error is that the PIC will not be found/recognized or the PIC will fail verification because it didn't program correctly. A Vcc error is usually a result of shorting +5 to ground. Who knows what you did to cause this error. A 10k pullup resistor was not the cause.
 
He installed the switch wrong and I bet a dollar to a donut thats it.
Cut the wire going to the switch and I bet it programs fine.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top