how to enable internal pull ups?
how to enable internal pull ups?
PIC 16F883 I wish to use has weak pull ups on port B? What I don't know if where and how do you enable them?
Do you do that in code or do you set some flags in picflash?
Do you do that in code or do you set some flags in picflash?
http://ww1.microchip.com/downloads/en/D ... df#page=49
3.4.2 WEAK PULL-UPS
Each of the PORTB pins has an individually configurable
internal weak pull-up. Control bits WPUB<7:0> enable or
disable each pull-up (see Register 3-7). Each weak
pull-up is automatically turned off when the port pin is
configured as an output. All pull-ups are disabled on a
Power-on Reset by the RBPU bit of the OPTION register.
Web Department Manager
hi,
you can try
HTH a bit
you can try
Code: Select all
procedure init;
begin
TRISB := 1 ; // port B input
option_reg.7 := 0 ; // enable individual pull-up
WPUB := %11111111 ; // all port b are in weak pull-up
end;
Yes I figured it out my self that you must use the bits number not name, something you can use with other registers.piort wrote:hi,
you can tryHTH a bit ;-)Code: Select all
procedure init; begin TRISB := 1 ; // port B input option_reg.7 := 0 ; // enable individual pull-up WPUB := %11111111 ; // all port b are in weak pull-up end;
Is the WPUB := %11111111 ; line needed if I wish all portb to have pull ups? Doesn't line option_reg.7 := 0 ; enables all at once?
No, it enables those that have respective WPUB bit set. Naturally, you may assume that WPUB is $FF at power-up (default state). Just don't complain if some day your application misbehaves .brkovich wrote:Is the WPUB := %11111111 ; line needed if I wish all portb to have pull ups? Doesn't line option_reg.7 := 0 ; enables all at once?
-
- Posts: 2
- Joined: 22 Mar 2011 16:54
Re:
hello!!anikolic wrote:http://ww1.microchip.com/downloads/en/D ... df#page=493.4.2 WEAK PULL-UPS
Each of the PORTB pins has an individually configurable
internal weak pull-up. Control bits WPUB<7:0> enable or
disable each pull-up (see Register 3-7). Each weak
pull-up is automatically turned off when the port pin is
configured as an output. All pull-ups are disabled on a
Power-on Reset by the RBPU bit of the OPTION register.
with regard to internal pull up for 16F690,
I am trying to put on portC the pulluped bits of protA but it does NOT WORK
here is the code
Code: Select all
//test per i pull up interni
//OSSERVAZIONE
// per la porta a non funziona per la b si :-(
void main()
{
trisa=0xff;
ANSEL=0;
ANSELH=0;
trisc=0;
OPTION_REG = (OPTION_REG & 0b01111111);
WPUA=0xFF;
do
{
portc =(porta>>4);
}
while(1);
}
Please can you tell me why??
-
- Posts: 69
- Joined: 28 Jan 2012 06:50
- Location: Pakistan
- Contact:
Re: how to enable internal pull ups?
silvestro71 its working.
-
- Posts: 10
- Joined: 09 Aug 2015 14:40
Re: how to enable internal pull ups?
so, how to enable internal pull ups portB for my pic16f877a? portB are i used to interface with keypad 4x4
Re: how to enable internal pull ups?
As usual it's all in the datasheet...read the section about PORTB or do a search for "pull"
-
- Posts: 10
- Joined: 09 Aug 2015 14:40
Re: how to enable internal pull ups?
I've written code like the one on datasheet but my keypad is still not working, so what's wrong with my code?hadv wrote:As usual it's all in the datasheet...read the section about PORTB or do a search for "pull"
Re: how to enable internal pull ups?
How to enable weak pull up resistor on all pins of PORTB except RB1 on PIC16F886
Re: how to enable internal pull ups?
It's explained in the datasheet:
In simple steps:Each of the PORTB pins has an individually configurable
internal weak pull-up. Control bits WPUB<7:0> enable or
disable each pull-up (see Register 3-7). Each weak
pull-up is automatically turned off when the port pin is
configured as an output. All pull-ups are disabled on a
Power-on Reset by the RBPU bit of the OPTION register.
- set bits in TRISB to declare chosen PORTB pins as inputs,
- clear respective ANSELH bits to declare chosen inputs as digital,
- clear chosen bits in WPUB register,
- clear the the RBPU bit of the OPTION register to activate pull-ups declared in WPUB.
Re: how to enable internal pull ups?
Found the answer
Last edited by dariods on 31 May 2023 18:16, edited 1 time in total.
Re: how to enable internal pull ups?
Code depends on what you intend to do with RB1
Code: Select all
TRISB:=%11111101; // or %11111111 if RB1 should be an input as well
ANSELH:=%00000000; // or %00000100 if RB1 (AN10) is to be analog input
WPUB:=%00000010;
OPTION_REG.NOT_RBPU:=0;