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.

Force the state of PIC I/O pins for reprogrammer use

Status
Not open for further replies.

ccurtis

Well-Known Member
Hello,
I have a tristate buffer output connected to the usart rx pin of my PIC, which also happens to be one of the pins used for reprogramming the PIC. I am not using the usart tx pin, except during connection to the pickit 3 programmer. The enable for the buffer is driven by one of the port pins. Is there is way to ensure that the port pin driving the enable is high to tri-state the buffer so I can connect my pickit 3 and then to reprogram it? My code sets the enable output low to enable the buffer, so it's in the low state when the PIC MCLR is held low (in reset) and my pickit3 can't connect to it.
 
Are you using low voltage programming? I though (high voltage) programming started with MCLR being driven to 12V and that overrides any other function on any pins.

Mike.
 
I don't use low voltage programming. Honestly, I haven't tried it yet, but I assume that the port pin driving the buffer enable will stay where the code last set it, and then if I try to connect the programmer it won't connect because the rx pin it being held by the buffer output.
 
I've used the programming pins as some of the data lines to an LCD without any problem (and mutiplexed keypad). I would just try it.

Mike.
Edit, you may need a (highish value) resistor in series with the RX pin to stop the sending device from messing with the PK2 communication. Resistor need to go between sending device and PK2 connection.
 
Last edited:
Okay, thanks. I was hoping that the PICKIT3 could possibly set the port pins to high impedance, or as inputs, before trying to connect, via the MCLR pin, but I guess that's not certain.
 
Okay, thanks. I was hoping that the PICKIT3 could possibly set the port pins to high impedance, or as inputs, before trying to connect, via the MCLR pin, but I guess that's not certain.

The pins won't stay how they were set, because the programmer resets the PIC - so it starts from the default reset status.

As Pommie mentioned, it's quite easy to use the programming pins for other uses, but you need to consider carefully what you connect to them, and alter which pins you use for what accordingly.

As far as I recall, reset sets all the I/O pins to inputs - so a simple pull-up resistor on the buffer enable pin should pull it high when the programmer resets it.
 
As far as I recall, reset sets all the I/O pins to inputs - so a simple pull-up resistor on the buffer enable pin should pull it high when the programmer resets it.
And then in your application code wait a bit before setting the enable output low.
The programmer usually toggles MCLR several times, so that should allow time for the PK3 to use either HVP or LVP.
 
I've never had a problem programming pics where the programming pins have dual function.
If it is a problem then just waiting for the clock to be stable is (probably) long enough. Which most people would (should) do.

Mike.
 
If you use HVP it's not normally a problem, but I've seen cases when using LVP and reprogramming previously programmed parts if the code immediately sets the programming pins as outputs. That can keep the part from being able to enter programming mode, depending on how fast the ICSP tries to switch it.

...just waiting for the clock to be stable is (probably) long enough. Which most people would (should) do.
Only if it matters... many times it doesn't.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top