PIC 18 IO internal weak pull-ups

Programming WPUR — Debut pic — Episode#09

J3
Jungletronics
2 min readNov 22, 2019

--

Pull-up resistors are very common when using microcontrollers (MCUs) or any digital logic device. ❤ git

Fig 1. Pull-ups resistor enable for button RB0

This tutorial will explain when and how to use pull-up resistors on the PIC18 Family.

For PIC18F4520

PORTB can be software programmed for internal weak pull-ups on all inputs.

For PIC18F45K202

Each of the PORTB pins has an individually controlled weak internal pull-up. When set, each bit of the WPUB register enables the corresponding pin pull-up. When cleared, the RBPU bit of the INTCON2 register enables pull-ups on all pins which also have their corresponding WPUB bit set.

When set, the RBPU bit disables all weak pull-ups.

The weak pull-up is automatically turned off when the port pin is configured as an output. The pull-ups are disabled on a Power-on Reset.

Here is the code:

In the next lesson let’s understand the Button Library from mikroC compiler :)

And that’s it!

Thanks a lot! See you in the next episode.

Bye!

Related posts:

1º Episode — IO: Debut pic — Pic 18 Hello World \o/ — Just initiating a magic journey throughout Microchip’s best seller pastille

2º Episode — IO: Debut pic — Pic 18 Push & Blink an LED — Let’s Unveil IO’s PIC18 Capabilities

3º Episode — IO: Debut pic — PIC 18 Push & Debounce! — Treating buttons’ Debounce

4º Episode — IO: Debut pic — PIC 18 Lighting LEDs In a Row! — Nice Special Effect

5º Episode — IO: Debut pic — PIC 18 Chasing LEDs — The net result is that LEDs seem to be chasing each other

6º Episode — IO: Debut pic — PIC 18 Double Chasing — The LEDs chase each other in both directions

7º Episode — IO: Debut pic — PIC 18 Ambulance Light — Algorithm for ambulance-flashing-light

8º Episode — IO: Debut pic — PIC 18 Random Flashing— Generating a random number

9º Episode — IO: Debut pic — PIC 18 internal weak pull-ups— How to programming WPUR

10º Episode — IO: Debut pic — Button Library — How to use mikroC PRO for PIC library

11º Episode — IO: Debut pic — Up Down Counter — How to use mikroC PRO for PIC library

--

--

J3
Jungletronics

😎 Gilberto Oliveira Jr | 🖥️ Computer Engineer | 🐍 Python | 🧩 C | 💎 Rails | 🤖 AI & IoT | ✍️