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.

Breadboard Programming for PIC16F877A

Status
Not open for further replies.

aaronchay

New Member
Hi, I would like to know can I just connect the wires from the Pickit 2 directly to the pins on my Microcontroller? Must I add a pull up resistor or something? I tried to connect the wires directly but I couldn't program it.
 
Hi, I would like to know can I just connect the wires from the Pickit 2 directly to the pins on my Microcontroller? Must I add a pull up resistor or something? I tried to connect the wires directly but I couldn't program it.
Yes you can.

Pin 1. VPP to MCLR pin on PIC. You need a 10K to 33K pullup resistor on this pin too.

Pin 2. VDD to VDD. The PICkit 2 can supply power to your target (the breadboard), but not too much. I forget the exact amount of current, but it's enough to do small circuits.

Pin 3. Ground to Ground

Pin 4. PGD to PGD pin on PIC.

Pin 5. PGC to PGC pin on PIC.

Here's a typical schematic showing how it's connected. See the upper left area.
**broken link removed**
 
Whats the pull-up for - I regularly connect my pickit2 directly to my breadboarded circuits and they work fine - apart from the times I connect the pins the wrong way round (i really need a keyed socket :( )
 
Whats the pull-up for - I regularly connect my pickit2 directly to my breadboarded circuits and they work fine - apart from the times I connect the pins the wrong way round (i really need a keyed socket :( )
The pullup is for when you try to run the circuit without the PICkit 2 connected. Keeps the reset pin from floating, which can cause random resets. As long as the PICkit 2 is connected it controls the pin. So it's just a good habit to get into.
 
ahh a good hint there, just thinking - most of my recent projects have used small pics, so ive probably had the mclr disabled and using the pin as an input - thats probably why i havn't had any problems.
 
Hi fut, thanks for the verification. I connected as instructed and did a Blank Check on my device using the pickit 2 Programmer. However, it stated "Program Memory is not blank starting at address 0x00000"
 
Hi fut, thanks for the verification. I connected as instructed and did a Blank Check on my device using the pickit 2 Programmer. However, it stated "Program Memory is not blank starting at address 0x00000"
It connects then? If so then try an erase. If all seems normal, program the chip with your hex file and continue.
 
It connects then? If so then try an erase. If all seems normal, program the chip with your hex file and continue.
I tried to program using the MPLAB Programmer. It shows the following error when I select Pickit2 as the programmer.

PKWarn0003: Unexpected device ID: Please verify that a PIC16F877A is correctly installed in the application. (Expected ID = 0xE20, ID Read = 0x0)

When I try to write, it shows the following error:
PK2Error0027: Failed verify (Address = 0x2007 - Expected Value 0x2FCF - Value Read 0x4B)
 
I tried to program using the MPLAB Programmer. It shows the following error when I select Pickit2 as the programmer.

PKWarn0003: Unexpected device ID: Please verify that a PIC16F877A is correctly installed in the application. (Expected ID = 0xE20, ID Read = 0x0)
Then it's not connecting. Trying to write is pointless until it does.

With the PIC wired properly, hit Programmer/Connect and it should connect to the PIC and tell you what type it is. If you can't get that to happen, the rest is never going to work.

If your project has the wrong target PIC specified that could cause the problem. Confirm that your project has the correct PIC selected.

The above was typed without MPLAB in front of me so I may have misnamed certain menus. Adjust to suit.
 
I tried to wire my P16F877A like this:
I can't tell anything from that jumble of wires. I would have to see the PICkit 2 end as well. You should try to get in the habit of wiring your breadboard more like **broken link removed**. Check out one of Pommie's breadboards if you want to see REALLY neat. Mine look sloppy beside his.

Rather than a bunch of loose wires as a programming cable you really should build some proper cables to make your life SO MUCH easier, and programming/debugging much more reliable (like 100% :p). Like this:

**broken link removed**

Look about halfway down in this thread for more pictures.

I tried using the Pickit2 programmer and checked for blank. It Displayed "Device was blank" until I connected the MCLR to ground then after that it coundn't work.
Umm... Why would you connect MCLR to ground?? As long as MCLR is held low the PIC is in reset. Reset means nothing happens until that pin goes high again. Put a pullup resistor (10K to 33K) from MCLR to VCC (5 volts) to make sure MCLR stays high.
 
Last edited:
I tried to wire my P16F877A like this:
Is that a resonator over at the left there? Keep the wires to it as short as possible!.

You should also connect all VDD and VSS pins, even though they usually work fine with just one pair connected.

But judging by a closer look at the picture, assuming the PICkit 2 end is good, it should work.

How long are the wires between the PICkit 2 and the breadboard? Keep them under 12 inches or so (even less if it's practical).

It's unlikely that this is the problem, but you should get in the habit of putting "decoupling" capacitors between the VDD and VSS pins of the PIC, as close as possible to the chip. Use 0.1uF ceramics for this. Sometimes you'll have trouble getting things to run properly without them.

If nothing else works, start up the PICkit 2 software (shut down MPLAB) and connect to the chip. Do an erase. Then shut that off and start MPLAB again and see if it connects normally then.
 
Last edited:
For programming purpose, why at all the resonator is needed, I wonder?Does he/she mean ICSP mode
 
Last edited:
When I run into this sort of problem I like to use the PICkit2 application instead of MPLAB. It seems to make connections work that have failed in MPLAB.

The only thing you should be looking at is connect (in MPLAB) or tools>check_communication in PICkit2. Do not bother with reading or erasing the chip till after these work.

You do not need a crystal or resinator to program the chip.

You do not need the pullup unless you intend to run then you also need a clock source (crystal or resonator).

I would add the 2 missing bypass caps. Check for shorts on the header that connects to the PICkit2.

I have never seen a PIC that was bad from the factory but it is possible but rare to mess one up.

The one thing I did not look at was the ICSP CLK and DATA lines. They could be mixed up.
 
I've checked the connection for the PGC and PGD. I've also checked for shorts on the wire itself.

I would add the 2 missing bypass caps. Check for shorts on the header that connects to the PICkit2.

Would you mind explaining this sentence?
 
I've checked the connection for the PGC and PGD. I've also checked for shorts on the wire itself.

I would add the 2 missing bypass caps. Check for shorts on the header that connects to the PICkit2.

Would you mind explaining this sentence?

OK. You already tested for shorts. The uC has 2 sets of power connections. Add a .1 uf capacitor between power and gnd on each side of the chip.

On the top side of the chip you need a cap between breadboard locations 18 and 19 and on the bottom between locations 20 and 21.

EDIT: I strongly suggest you use the PICkit2 application while you attempt to get the connection established. I was just working with a 18F2321 that I programmed with MPLAB. The processor was running and MPLAB could not connect. I switched to PICkit2 and it connected. Once you have a working connection switch back to MPLAB.
 
Last edited:
Would I be able to do fine without the capacitors at the moment? I would still be able to program right? I also tried to detect my PIC18F452 and I got the same error too. I'm using the Pickit2 Application.
 
Would I be able to do fine without the capacitors at the moment? I would still be able to program right?

actually - no
omitting the capacitor on the power pins (as close as possible to the pic) will usually lead to bunch of "strange" behaviours, one of the often seen one is "pickit does not recognise my uC / pickit do not want to program / read my uC"

just add a capacitors on the power pins, at least 0.1uF but any bigger will do the job, even some 100uF electrolyte will solve the problem just pay attention to polarize it properly
 
tried adding the capacitors already. No difference. Do I have to do anything on the software part?

I opened Pickit2, Go to Programmer - Manually select Device and I chose PIC16F877A
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top