Using PIC Microcontroller pins ICSPCLK and ICSPDAT as outputs.

Thread Starter

Mussawar

Joined Oct 17, 2011
157
Hi,
(My apologies for bad English.)
Usually I leave these two pins dedicated to ICSP but in a recent project, I'm short for pins so have no choice but to use them as I/O. PIC is 16f886 with SMD package.
In the project, these pins are supposed to drive transistors to operate relays. System is often updated in the field and chip can't always be removed from board since it's SMD package.
I know that while programming with ICSP, signal waveform might be distorted because of external circuitry.
What value of base resistor you suggest that can be used to drive transistor but also can safely able to program through ICSP.?
or is there any other solution to isolate ICSP pins from external circuitry? Any advice is strongly welcomed.
Regards.
Untitled.png
 

MaxHeadRoom

Joined Jul 18, 2013
30,557
Can you not use a Mosfet in place of the transistor?
These are voltage driven (transconductance) devices, not current as is with the transistor !
I always practice this method where possible, especially with Pic micros etc.
 

trebla

Joined Jun 29, 2019
599
What value of base resistor you suggest that can be used to drive transistor but also can safely able to program through ICSP
Data and clock lines are most sensitive to pull-up resistors and added capacitors. I use 1k resistors to base and have sometimes problems only with the PicKit3 and long programming cable. If the base resistor is around 4k then in theory the interference will be minimal. But it depends how much the transistor needs base current to be open fully. If you use mosfet then you need a pulldown resistor (10k) from gate to VSS to eliminate sporadic behavior at MCU startup.
 

Thread Starter

Mussawar

Joined Oct 17, 2011
157
Can you not use a Mosfet in place of the transistor?
These are voltage driven (transconductance) devices, not current as is with the transistor !
I always practice this method where possible, especially with Pic micros etc.
Thanks for reply.
Using MOFET is really a good choice. I'm currently using transistors because I've lot of them in my hand (around 2000 pcs). I think I should use FETs at least on these two pins. That's great.
 

Thread Starter

Mussawar

Joined Oct 17, 2011
157
Data and clock lines are most sensitive to pull-up resistors and added capacitors. I use 1k resistors to base and have sometimes problems only with the PicKit3 and long programming cable. If the base resistor is around 4k then in theory the interference will be minimal. But it depends how much the transistor needs base current to be open fully. If you use mosfet then you need a pulldown resistor (10k) from gate to VSS to eliminate sporadic behavior at MCU startup.
Thanks for reply.
I'm designing the project but unfortunately I don't have a test bench at the place for some time so I can only simulate the circuit. That's why I can't test practical results. I already know these transistors (2SC828) can drive the relay successfully with a 4.7k base resistor from a PIC but not sure that it will be OK for ICSP or not. As you recommended, 4.7k should work fine.
And if I use MOSFET for these two outputs, is circuit given below OK for the purpose? What if the pull down resistor value is 100k instead of 10k? Will it make any significant difference?
Regards,
Untitled.png
 

trebla

Joined Jun 29, 2019
599
And if I use MOSFET for these two outputs, is circuit given below OK for the purpose? What if the pull down resistor value is 100k instead of 10k? Will it make any significant difference?
Your circuit will be ok, i use 10k pulldown resistors and there is no interference during programming. When PIC starts then during reset condition all pins are inputs so the mosfet gate will be floating and may open the channel. PIC internal pullups are around 200k and may interfere with 100k pull-down resistor. With 10k resistor you are in the safer side. 2N6660 max current is 1.5A and full open channel resistance is 3-5 ohm so you must calculate how much power will be dissipated on this mosfet (P = load_current X load_current X channel_resistance).
 

Thread Starter

Mussawar

Joined Oct 17, 2011
157
2N6660 max current is 1.5A and full open channel resistance is 3-5 ohm so you must calculate how much power will be dissipated on this mosfet (P = load_current X load_current X channel_resistance).
I only need to drive a small relay which draw 7mA at 24V or let it be 10mA Max. So imo it would be safe.
Thanks for your time. :)
 
Top