[SOLVED (kinda)] For anyone using PicKit3 (question?, bug?)

Thread Starter

KansaiRobot

Joined Jan 15, 2010
324
Hello everybody and thanks always.

Since this year I am using the Pickit3 and I find it great specially for on board programming and debugging.
However today I found something curious that puzzle me and would like to hear your expert advice and experience.

I am using a PIC182550. The pickit PGD and PGC connects to the ports B7 and B6 (PGM although not used correspond to B5)

I wrote a program where I turn on and off pins B0~B3. No problem with that.

The thing is I am trying to use pins B4 and B5 to light LEDs. B4 works but B5 does not work.

I change my program (thinking maybe that my pin is damaged) to light LEDs through ports B6 and B7. Then none of the pins worked anymore.
(when you debug the program you can see that they work as they should, but once you program it in not-debug mode they dont work anymore)
I stopped using B6 and B7 and pins B0~B4 started working again.

Conclusion: When using PicKit3 you can not program the pins that it uses for PGD PGC and PGM! Ergo it is a waste of three useful pins!

Does anyone have a similar experience??
 

MaxHeadRoom

Joined Jul 18, 2013
21,632
All the Picmicro boards I have do not have anything connected to B5, the ICDconnector from 1-6 is /MCLR, +5, 0v, RB7, Rb6, with pin 6 N/C.
Max.
 

JohnInTX

Joined Jun 26, 2012
4,344
Make sure LVP in CONFIG4L is explicitly DISABLED in the config bits. RB5 is dedicated to LVP by default. Disabling LVP restores RB5 to an I/O.
RB6 and RB7 are assigned by DEBUG/ in CONFIG4L. Be sure your config bits reflect this. MPLAB will usually flip the bits accordingly if you have correctly used the DEBUG/RELEASE switches (in 8.x) or set up your project configs in MPLABX. With proper programming/config, you can recover the use of the pins.

But you have a point about RB6 and 7. When used with the debugger, its hard to find a useful function for them that is agreeable with their debugging function. I usually assign them to easy things like a status LED or a resistor isolated configuration jumper/address switch etc. When debugging, I use a assemble/compile time switch to fake up the desired input or output on the two pins. For release builds without the debugger, it assembles/compiles the normal code to use the pins.

Its a beating to lose 2 pins but the alternative is an expensive ICE that can have its own set of problems.
 

ErnieM

Joined Apr 24, 2011
8,058
Conclusion: When using PicKit3 you can not program the pins that it uses for PGD PGC and PGM! Ergo it is a waste of three useful pins!
I would hardly call programming and debugging a waste!

I've never used LVP so cut PGM out of your list. I use that pin freely. The PICkits may have 6 pins but I only connect 5 of them.

I prefer to reserve PGD and PGC for debugging use so I leave them out of my list when selecting pins for desired functions. Yeah, it can be a PITA to loose them but it's worse not having debugging functions on my hardware.

For the very seldom times I need a very small package and have no free pins I'll develop the software on a breadboard with a different PIC, ring out all the bugs, then recompile for a smaller device in production.
 

Thread Starter

KansaiRobot

Joined Jan 15, 2010
324
I would hardly call programming and debugging a waste!

I've never used LVP so cut PGM out of your list. I use that pin freely. The PICkits may have 6 pins but I only connect 5 of them.

I prefer to reserve PGD and PGC for debugging use so I leave them out of my list when selecting pins for desired functions. Yeah, it can be a PITA to loose them but it's worse not having debugging functions on my hardware.

For the very seldom times I need a very small package and have no free pins I'll develop the software on a breadboard with a different PIC, ring out all the bugs, then recompile for a smaller device in production.
I also only connect 5 of them. So do you explicitly disable LVP from PGM??
My problem and what I have observed is that I can not program or use that pin as it is. It does not respond to the use it is programmed for (become on or off) . JohnInTX observed that I have to explicitly configurate RB5
 

JohnInTX

Joined Jun 26, 2012
4,344
I also only connect 5 of them. So do you explicitly disable LVP from PGM??
On this part and others that support LowVoltageProgramming you have to do exactly that by setting up CONFIG bits. Of course, you also have to make sure that any shared functions (analog input, shared peripheral etc.) are handled.
 

NorthGuy

Joined Jun 28, 2014
611
It is also nothing wrong with abandoning pre-historc PICs with PGM pins and getting newer, better, and cheaper ones.
 

DerStrom8

Joined Feb 20, 2011
2,390
You should be able to program RB6 and RB7, you just can't use them while the PICkit3 is attached. The PICkit3 uses the PGC and PGD pins for programming (for Clock and Data connections), so trying to operate B6/7 while the PICkit is connected is a bad idea. Try programming those pins, disconnect the programmer, then power up the chip from an external source. I imagine RB6 and RB7 will then work.
 

OBW0549

Joined Mar 2, 2015
3,566
And what might they be?
Of the PICs I've used (or considered using) recently, the PIC10F322, PIC12F675, PIC12F683 and PIC16F1847 all have no PGM pin, only PGC and PGD.

And AFAIK, none of the 16-bit PICs (PIC24F, dsPIC30F/33F/33E) has a PGM pin.
 

ErnieM

Joined Apr 24, 2011
8,058
Of the PICs I've used (or considered using) recently, the PIC10F322, PIC12F675, PIC12F683 and PIC16F1847 all have no PGM pin, only PGC and PGD.
And AFAIK, none of the 16-bit PICs (PIC24F, dsPIC30F/33F/33E) has a PGM pin.
Oh, THAT pin. I misread NorthGuys post as there is nothing "pre-historc" (sic) about these parts. In fact, they are amoung the latest designs.

Once upon a time the MCLR needed the high voltage to program the internal EEPROM memory. Hey, you even had to load them with an 8 bit data word! Now that parts are serial and flash based there is no need for a higher voltage, and all the high voltage does is trip a comparator allowing the low voltage programming to happen.

The low voltage programmin (LVP) is a recent option to keep the high voltage out of the boards for in circuit programming.

You should be able to program RB6 and RB7, you just can't use them while the PICkit3 is attached.
Excellent point, just something so obvious to me I forget these things.

One must still use some care so the programmer is not overloaded when trying to drive these pins. Microchip has app notes about what kinds of circuitry to avoid and what is acceptable.
 
Once you get experienced with the PIC you can use a ZIF socket attached to PICKIT3 for programming PIC and use all the pins.
Once you are experienced you wont need as many debug go's.
I use templates from previous projects to get up and running with a new project.
My previous projects have a macro .asm file with loads of useful functions like add16, add32, DEC16, INC16 SUB16 etc etc
 

ErnieM

Joined Apr 24, 2011
8,058
FYP:

Once you have experience with the PIC you will skip the ZIF socket and connect the PICKIT directly to your target for programming and debug.
Once you have experienced you will realize how essential the debug stage is, especially code walking each and every procedure you write.
Templates only fill in the most basic pieces of the puzzle and is of an aid only on the first day.
Library code will do the heavy lifting when you want to add the most useful things. As they are in C you will learn to love that compiler.
 

Thread Starter

KansaiRobot

Joined Jan 15, 2010
324
You should be able to program RB6 and RB7, you just can't use them while the PICkit3 is attached. The PICkit3 uses the PGC and PGD pins for programming (for Clock and Data connections), so trying to operate B6/7 while the PICkit is connected is a bad idea. Try programming those pins, disconnect the programmer, then power up the chip from an external source. I imagine RB6 and RB7 will then work.
I did precisely that. They don't work. Furthermore , the whole port B does not work.
Modify the program again to not use those pins...voila! B0~B4 work again. strange isnt it?


EDIT: Just in case guys, I am not talking about using those pins for programming and using at the same time lol...:) It is obvious you have to disconnect the programmer first... the thing is they dont work even then.
 
Last edited:

ErnieM

Joined Apr 24, 2011
8,058
It sounds like time to try out your code on the MPLAB simulator. See if your code can wiggle the pins in sim. If not, it's never going to work on the real hardware.

If you can't sim, you can't win!
 

Thread Starter

KansaiRobot

Joined Jan 15, 2010
324
It sounds like time to try out your code on the MPLAB simulator. See if your code can wiggle the pins in sim. If not, it's never going to work on the real hardware.

If you can't sim, you can't win!
I haven't tried the simulator but I have run the code step by step(debug). It does wiggle the pins.
 

Thread Starter

KansaiRobot

Joined Jan 15, 2010
324
Yes, apparently you have to disable LVP explicitly... sigh.. it is causing me some headaches

EDIT: Solved!

I havent tried RB6 or RB7 so I dont know if this solve that problem but for RB5 if you want to use it you have do disable LVP.

In my compiler
Code:
#pragma config LVP = OFF
 
Last edited:
Top