1
\$\begingroup\$

I'm using a PIC 18F4550 to blink an LED in a breadboard through a resistor. I think the circuit is correct because a simulation with Proteus works fine.

The physical circuit doesn't work unless I hold the LED with my hand. When I release my hand it stops.

I used a typical 0.1uF ceramic decoupling capacitor between Vcc and Vdd.

now I connected the two pairs of (vcc ,ground)

What could be the cause of my problem?

enter image description here

\$\endgroup\$
13
  • 1
    \$\begingroup\$ And what makes you think that connecting both pairs of power pins is optional? \$\endgroup\$
    – Matt Young
    Aug 19, 2014 at 17:12
  • 1
    \$\begingroup\$ All power pins should be connected, also the wires from C1, C2 to Vss should be quite short. It should work when you do that, though 20MHz in a breadboard is usually not recommended. \$\endgroup\$ Aug 19, 2014 at 17:13
  • 3
    \$\begingroup\$ It's a very sad day when we close questions about key basic topics as "unclear" after an answer has already solved - and implicitly clarified - the issues! \$\endgroup\$ Aug 19, 2014 at 18:01
  • 2
    \$\begingroup\$ @ChrisStratton Check the revision history. The O.P. has removed the schematic from the post. Are we supposed to provide answers when the O.P. is pulling the rug from under our feet? That's not sad; that's irritating. \$\endgroup\$ Aug 19, 2014 at 18:09
  • 3
    \$\begingroup\$ @NickAlexeev - if you don't have enough information to answer, then don't. But don't presume to tell others who may have more relevant expertise that they do not have the information they need. Doing so merely cements the poor reputation of this site's dominant clique. \$\endgroup\$ Aug 19, 2014 at 18:36

1 Answer 1

7
\$\begingroup\$

Connecting BOTH pairs of VDD/VSS is absolutely required. Connecting only one pair is not optional and may produce unpredictable results. And it's wise to put decoupling capacitors on each pair separately.

The behavior associated with the proximity to your hand may be because you left the PGM pin unconnected. If you have LVP enabled (one of the configuration bits in your code), the PIC will go into programming mode if the PGM pin is driven high. The PGM pin should be tied to ground for normal operation. But if that pin is left floating, it acts like an antenna and any nearby electrostatic force (your hand) may cause it to swing high or low. However, if you do not have LVP enabled, that is unlikely the problem.

On another note, Microchip recommends a resistor between MCLR and VDD. A 10k resistor is common.

\$\endgroup\$
4
  • \$\begingroup\$ it works fine but by putting PGM down (to ground), are you sure PGM should be high (vcc) \$\endgroup\$
    – makouda
    Aug 19, 2014 at 17:44
  • 1
    \$\begingroup\$ As I said in my answer, it will go into programming mode if it's driven high. So forcing it to ground, as you have now done, allows the PIC to run normally. Just remember to remove that wire when you program it or your programmer may not work. \$\endgroup\$
    – Dan Laks
    Aug 19, 2014 at 17:49
  • \$\begingroup\$ I've edited my answer to clarify the PGM should be tied to ground for normal operation. \$\endgroup\$
    – Dan Laks
    Aug 19, 2014 at 17:52
  • 1
    \$\begingroup\$ +1 Spot on! I had the same problem with the PGM pin left floating and I've been scratching my head for days over it. \$\endgroup\$
    – m.Alin
    Aug 19, 2014 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.