PDA

View Full Version : Weak Pull-up on 12F683



BobP
- 10th April 2006, 22:28
Just started to us the 12F683 and I have searched the forum and the datasheet but can't get the pull-ups working on the input of the attached program!

If I ground the input (GP5) the program behaves as expected rapid LED flashing. If I connect the input to 5v I again get the LED to flash with the longer flash. But disconnecting the input (floating) from either state does not change the flash sequence.

I suspect (hope!) it is something simple but can’t see it!
************************************************** *
@ DEVICE pic12F683, INTRC_OSC_NOCLKOUT
@ DEVICE pic12F683, WDT_OFF
@ DEVICE pic12F683, PWRT_ON
@ DEVICE pic12F683, BOD_ON
@ DEVICE pic12F683, MCLR_OFF
@ DEVICE pic12F683, IESO_OFF
@ DEVICE pic12F683, FCMEN_OFF
@ DEVICE pic12F683, CPD_OFF
@ DEVICE pic12F683, PROTECT_OFF

OSCCON = $60 'sets the oscillator speed
DEFINE OSC 4 'Oscillator speed in MHz
CMCON0 = 7 ' Comparators off
ANSEL=0
TRISIO=%01011
VRCON=0
WPU=%00110111 ' Pull-ups on
OPTION_REG.7=0 ' Enable internal pull-ups

LED VAR GPIO.2
LEVEL VAR GPIO.5

st:
LED =1
PAUSE 200
LED =0
PAUSE 200
IF LEVEL=1 THEN ST
LED =1
PAUSE 1000
LED =0
PAUSE 200
GOTO st
END
***************************************

Thanks,
Bob

Bruce
- 10th April 2006, 23:26
Using a partial binary number like TRISIO=%01011 does not set GPIO.5 up as
an input.

The remaining upper 3-bits are by default 0's, so you're forcing GPIO.5 to be
an output.

Output port latches power-up with an undetermined value, so you don't really
know if you're shorting the pin with a high or low, but you definitely are.

Even pins configured as outputs can be read, so while you're grounding or
taking the pin to Vcc, it's still going to read the pin & react accordingly.

Make the pin an input. Should clear up whatever problems you're having.

paul borgmeier
- 10th April 2006, 23:29
It does not appear you have set GP5 as an input.

Try:

TRISIO=%101011

Good Luck,

Paul Borgmeier
Salt Lake City, Utah
USA

edit - looks like I hit return 3 minutes after Bruce did (at least we match) pb

BobP
- 12th April 2006, 22:29
Many thanks everyone. It was the TRISIO data. As you identified I didn't enable GPIO.5 as an input!
It was late and too much coffee. It didn't help the software acting as if the port was an input...

Now working as expected.

Thanks,
BobP