Pull-up internas como activarlas?

For general Flowcode discussion that does not belong in the other sections.
Post Reply
Carmelo
Posts: 132
http://meble-kuchenne.info.pl
Joined: Thu Oct 14, 2021 10:04 am
Has thanked: 53 times
Been thanked: 4 times

Pull-up internas como activarlas?

Post 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.
Last edited by Carmelo on Sat Jul 26, 2025 11:41 pm, edited 1 time in total.

chipfryer27
Valued Contributor
Posts: 1640
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 362 times
Been thanked: 575 times

Re: Pullu-up internas como activarlas?

Post 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

Carmelo
Posts: 132
Joined: Thu Oct 14, 2021 10:04 am
Has thanked: 53 times
Been thanked: 4 times

Re: Pull-up internas como activarlas?

Post 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.
Last edited by Carmelo on Sun Jul 27, 2025 12:02 am, edited 1 time in total.

chipfryer27
Valued Contributor
Posts: 1640
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 362 times
Been thanked: 575 times

Re: Pull-up internas como activarlas?

Post 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

Carmelo
Posts: 132
Joined: Thu Oct 14, 2021 10:04 am
Has thanked: 53 times
Been thanked: 4 times

Re: Pull-up internas como activarlas?

Post 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;

Carmelo
Posts: 132
Joined: Thu Oct 14, 2021 10:04 am
Has thanked: 53 times
Been thanked: 4 times

Re: Pull-up internas como activarlas?

Post 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.

chipfryer27
Valued Contributor
Posts: 1640
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 362 times
Been thanked: 575 times

Re: Pull-up internas como activarlas?

Post by chipfryer27 »

Hi

Glad you have it working. I too have been caught by names before :)

Regards

Post Reply