PDA

View Full Version : Weak pull-ups, WPU, and 12F683



RussMartin
- 2nd February 2009, 21:11
I'm running into a screwy problem:

Using PBP and a 12F683 in a breadboard configuration, I've enabled the internal weak pull-ups on two pins, GPIO.2 and GPIO.1 (WPU=%00000110). These pins have simple NO pushbuttons to ground. I've reduced the essential parts of the circuit and program to one switch and a blinky.

The results are flaky.

Often, on power-up, the circuit behaves as if the switch is closed and held closed. Other times it starts normally, then jumps into the switch closed routine. (It doesn't behave much differently with the internal pull-ups disabled!)

This goes away and everything is hunky-dory if I put external 10K pull-ups on the switches.

ESD? Transients? A consequence of breadboarding? I'm nearing wits' end.

mjmccarron
- 2nd February 2009, 21:21
Hi Russ,

I would lean towards an order of operations issue. When the chip does a power on reset, it comes up in analog mode and the WPU's are turned off. The pins could still be floating when the program looks at them for the first time???

Fredrick
- 2nd February 2009, 21:52
Can you post the code you are using?

Melanie
- 2nd February 2009, 21:54
I would actually check...

1. That you have DISABLED the ANALOG ADC on those pins...

ANSEL=%00000000

2. That you have DISABLED the COMPARATORS on those pins...

CMCON0=%00000111

3. That you have set TRISIO to INPUT on those pins...

TRISIO=%00001110

4. And that you have enabled the Weak Pull-UP's properly...

WPU=%00000110
OPTION_REG.7=0 ' <<< Bet you forgot this one!!!!

And now you can do your Buttons from this point onwards... but just in case, I'd give it a few mS timeout first...

RussMartin
- 2nd February 2009, 22:14
Melanie!

ANSEL, yes.
CMCON0, yes.
TRSIO, yes.
WPU, yes.

OPTION_REG.7=0 . . . Oh, s**t! (And you win that bet!)

DUH!

Everything is now both hunky and dory.

Thanks!