PDA

View Full Version : 12F683 internal pull up



hvacrtech
- 24th July 2008, 19:08
Seems that internal pull up resistors not working?

Simple code to work with. I am using GPIO.5 as input as digital. The LED still blinks from GPIO.2. The internal pull up dont work as expected to keep input low. Am I missing something?

CODE:
Include "bs2defs.bas"
@ DEVICE PIC12F683,MCLR_OFF,INTRC_OSC_NOCLKOUT,WDT_OFF,BOD_ ON, PWRT_ON


A var word
OSCCON = %01100000 ' Internal 4MHz osc
ADCON0 = 0 ' A/D off
CMCON0 = 7 ' Comparators off
ANSEL = 0 ' Set all digital
WPU = %00110111 '0 ' Internal pull-ups = off ISSUE?????? Register 4.3
OPTION_REG.7=0 'Enable internal pull-ups
TRISIO = %100000 'set GPIO.5 as input, rest output
test var GPIO.5 'Input

START:

LOW 2
PAUSE 100

if test = 1 then high 2:PAUSE 1000


goto START

The LED still flashes. it should not be flashing unless input is triggered from +5 volt.

skimask
- 24th July 2008, 20:17
The internal pull up is a weak internal pull up, easy to over ride it with almost any external drive (parameter D070 in the datasheet), only about 250uA of current for pullup.

Bruce
- 24th July 2008, 20:18
If you have internal pull-ups ON, and you're testing the input pin for logic 1, the only
way your LED shoud NOT blink would be when GPIO.5 is pulled to ground.

hvacrtech
- 24th July 2008, 20:46
Got it working, added INTCON=7. changed input to PULSIN. Everyting is working well.

OOPS should be INTCON=0 not INTCON=7.

skimask
- 24th July 2008, 21:25
Got it working, added INTCON=7. changed input to PULSIN. Everyting is working well.
OOPS should be INTCON=0 not INTCON=7.

I'm not seeing where the INTCON or the PULSIN statements should make a difference...
And if you look back at your first post:

Simple code to work with. I am using GPIO.5 as input as digital. The LED still blinks from GPIO.2. The internal pull up dont work as expected to keep input low. Am I missing something?
Why would the internal pull UP work as expected to keep the input LOW?

Bruce
- 24th July 2008, 23:00
OOPS should be INTCON=0 not INTCON=7.
Err, OK, but INTCON is already zero, by default, at power-up. Not sure where PULSIN fits into the grand scheme, but at least you got it working...;o}

hvacrtech
- 26th July 2008, 19:22
If you have internal pull-ups ON, and you're testing the input pin for logic 1, the only
way your LED shoud NOT blink would be when GPIO.5 is pulled to ground.


That way it been erratic behavior and You are right about that the led should not blink when GPIO.5 is opened. that way when I opened the path from ground, the led still blinks. After I added INTCON=0 to it, it behaves much better and dont blink when opened. When I closed the GPIO.5 to ground, the led did blink.

I dont know why but added INTCON=0, system stablizes. Like other PIC I know dont have issues with out this configuration. Maybe it a requirement?

Bruce
- 27th July 2008, 02:35
Clearing INTCON should not be necessary unless you had previously placed some value
in it you need to clear. At power on INTCON by default is already clear.

If it wasn't you could really have some odd behaviour with unexpected interrupts firing.