PDA

View Full Version : Enabling weak internal pull up resistors on port B



dbodenheimer
- 27th July 2010, 15:50
I have some switches that I need to install on my system. I have 4 of them and I currently have them hooked to PortB.4-7. I understand that there are internal pull up resistors that can be enabled for this port. It's my understanding that they are disabled after a power on reset.

Can someone tell me how to enable these resistors from PICBasic Pro?

Thanks,

Dave

dbodenheimer
- 27th July 2010, 15:52
I should have mentioned that I'm using a 16F876 PIC and it does have the internal resistors.

LinkMTech
- 27th July 2010, 16:57
Setting your configs at the top of your program will ensure that the internal pull ups are always enabled from the beginning even when power is interrupted because that's where it will start anyways.
I suppose if you enable the internal pull ups in a subroutine that is called after certain conditions, then yes, you can lose that setup until that condition is called again after a power reset.
The bit has to be cleared per data sheet so: OPTION_REG.7=0

DDDvvv
- 27th July 2010, 17:03
datasheet says that they are controlled by OPTION_REG , bit 7 (RPBU). (pg. 45)

same page indicates that on reset, this register value defaults to all bits being set, (1111 1111),

so, hook up your switches, dont change nothin' and switch away:cool:

dbodenheimer
- 27th July 2010, 18:11
Ok, So let's say for some reason the OPTION_REG is getting reset. What syntax do I use in PicBasic Pro to set it again?

LinkMTech
- 27th July 2010, 21:00
ok, so let's say for some reason the option_reg is getting reset. What syntax do i use in picbasic pro to set it again?
option_reg.7=0

malc-c
- 28th July 2010, 14:30
I've often found internal pull-ups troublesome and simply use small external resistors between 4.7K and 10K depending on the input device

Plcguy
- 7th October 2010, 20:23
In that thought process, it appears option_reg.7 = 0 sets all 4 port B pull ups on an 16F88. Can one of those pins then be used as a serial output? I don't see where you can set individual pins.......

HankMcSpank
- 8th October 2010, 15:55
In that thought process, it appears option_reg.7 = 0 sets all 4 port B pull ups on an 16F88. Can one of those pins then be used as a serial output? I don't see where you can set individual pins.......

On a 16f690, I do this to get the weak pullups working...



option_reg.7=0 ' Enable WPUs by individual pin
WPUB = %11110000 'enable weak pullups on RB7, RB6, RB5 & RB4


It all works weally weakpullup-tastically (but disable any other PIC stuff that maybe sharing those ports...and make sure they're all set as inputs)