Page 1 of 1
Pull-up internas como activarlas?
Posted: Sat Jul 26, 2025 8:12 pm
by Carmelo
Hola,
Que sentencia ha y que utilizar en el bloque de código C para activar las resistencias internas de las líneas RB4, RB5, RB6 y RB7 en un microcontrolador Pic 16F886.
C.
Re: Pullu-up internas como activarlas?
Posted: Sat Jul 26, 2025 10:29 pm
by chipfryer27
Hi
If you look in the datasheet, section 3.4.2 Weak Pull-Ups, you will find the details of the register you need to set. The register is 8-bits wide for Port B so you can select / set whichever bits you need.
In the C-Code block enter the register name and value (e.g. REG=0b11110000).
Regards
Re: Pull-up internas como activarlas?
Posted: Sat Jul 26, 2025 11:28 pm
by Carmelo
Gracias por la respuesta.
Entonces entiendo que en el bloque C habría que escribir lo siguiente:
OPTION_REGbits.RBPU = 0;
Para habilitar de forma general las pull-up y después:
WPUB=0b11110000;
Para habilitar de forma individual las resistencias de la pines RB4 a RB7
C.
Re: Pull-up internas como activarlas?
Posted: Sat Jul 26, 2025 11:58 pm
by chipfryer27
Hi
Bits are 7 - 0 so to set RB7-RB4 it would be 0b11110000
Regards
PS
When setting register bits I find it helpful to use binary but of course you can use hex or decimal if you prefer
0b11110000 = 0xF0 = 240
Re: Pull-up internas como activarlas?
Posted: Sun Jul 27, 2025 12:04 am
by Carmelo
Grcacias por la respuesta.
me equivoque al escribir el codigo del registro WPUB.
En concreto las lineas a insertar serian:
OPTION_REGbits.RBPU = 0;
WPUB=0b11110000;
Re: Pull-up internas como activarlas?
Posted: Sun Jul 27, 2025 6:28 pm
by Carmelo
Hola,
Bueno al final con la sentencia: OPTION_REGbits.RBPU = 0;
Daba error al compilar
Lo cambie por: OPTION_REG = 0b00000000;
Y ahora va bien.
C.
Re: Pull-up internas como activarlas?
Posted: Sun Jul 27, 2025 6:34 pm
by chipfryer27
Hi
Glad you have it working. I too have been caught by names before
Regards