Skip to content

Main PIC18F4550 registers

This page is the PIC18F4550 register catalog. If you have not read Basic architecture yet, start there: it explains SFR, GPR, WREG, STATUS, BSR, and PC with assembly examples.

Here you will see which registers exist, what each one does, and how to use them in code.

Data RAM mixes two kinds of locations:

TypeWhat it isExamples
SFRControl internal hardwareTRISB, LATB, INTCON, TMR0
GPRYour program variablescounter, temp (declared with RES)

The PIC18F4550 organizes RAM into 16 banks (0 through 15). Register BSR selects the active bank. Many important SFRs sit in the access bank (ACCESS): you can read and write them without changing BSR.

These registers do not control a specific peripheral; they belong to the processor core. See Architecture for detailed examples; here is a quick reference:

RegisterFunction
WREG8-bit accumulator. Source/destination for many instructions.
STATUSFlags Z, C, DC, OV, N after arithmetic/logic operations.
BSRSelects memory bank (0–15).
PCProgram counter. Points to the next instruction in Flash.
STKPTR / StackPushes return addresses on CALL/RETURN and interrupts.

Each port (A, B, C, D, E) has three SFRs with different roles:

RegisterRead / writeFunction
TRISxWritePin direction: 1 = input, 0 = output
LATxWriteOutput value written to the latch (does not read the physical pin)
PORTxReadActual pin level (useful for inputs and switches)

PIC18F4550 ports (40-pin PDIP):

PortPinsCourse notes
ARA0–RA5Some analog pins
BRB0–RB7RB0 = INT0; RB4–RB7 = change interrupt
CRC0–RC7RC6/RC7 = UART (TX/RX)
DRD0–RD7LCD in lab practices
ERE0–RE2Analog inputs
BCF TRISB, 0 ; RB0 as output (TRISB bit 0 = 0)
BSF LATB, 0 ; RB0 high → LED on
BSF TRISB, 3 ; RB3 as input (TRISB bit 3 = 1)
BTFSS PORTB, 3 ; skip if RB3 is 1 (button released, depends on wiring)
GOTO button_pressed ; if RB3 = 0 → jump to destination
; button released (RB3 = 1) ...
GOTO done_button
button_pressed:
; button pressed (RB3 = 0) ...
done_button:

More examples in GPIO and the quick register guide.

Interrupts use several SFRs in sequence: enablecheck flagrun ISRclear flagRETFIE.

Global control — INTCON, INTCON2, INTCON3

Section titled “Global control — INTCON, INTCON2, INTCON3”
Register / bitFunction
INTCON.GIEGlobal Interrupt Enable — master switch (1 = interrupts active)
INTCON.PEIEEnables peripheral interrupts (timers, UART, ADC…)
INTCON.TMR0IFFlag: Timer0 overflowed
INTCON2 / INTCON3External INT0–INT2, RB port, priorities
FamilyPurpose
PIE1, PIE2Peripheral Interrupt Enable — enable the source (e.g. TMR0IE)
PIR1, PIR2Peripheral Interrupt Request — flag that the event occurred
IPR1, IPR2High/low priority for each source

Typical Timer0 flow:

BSF INTCON, GIE ; turn on global switch
BSF INTCON, PEIE ; allow peripheral interrupts
BSF PIE1, TMR0IE ; enable Timer0 interrupt
; ... in the ISR ...
BCF INTCON, TMR0IF ; clear flag before RETFIE
RETFIE

Full detail in Interrupts.

Summary by module — full table in Quick register guide:

ModuleKey registersTopic
Timer0T0CON, TMR0L, TMR0HTimer 0
Timer1/2T1CON, T2CON, PR2Timers
ADCADCON0, ADCON1, ADCON2, ADRESH/LADC
UARTTXSTA, RCSTA, SPBRG, TXREG, RCREGUART
PWM/CCPCCP1CON, CCPR1L, PR2PWM and CCP
SPI/I2CSSPSTAT, SSPCON1SPI/I2C
; Variable section (e.g. after UDATA or at end of file):
counter RES 1 ; define name + reserve 1 byte
; Usage:
INCF counter, F
MOVF counter, W

The name is your variable; an SFR has a fixed factory name.

What is the difference between reading PORTB and writing LATB?

PORTB reflects electrical pin levels (useful for inputs). LATB changes the latch output value without reading the physical pin.

What does BSR do?

It selects the RAM bank (0–15) when accessing an address. Many SFRs do not need it because they are in the ACCESS bank.

What is INTCON.GIE for?

It enables or disables all interrupts globally.

Interactive exam

PIC18 registers

Based on: Clase Tema 2 y 3 (1).pdf

0 of 0 answered

Which register defines if a pin is input or output?
To write an output without reading the physical pin you should use...
In TRISB, a bit set to 1 means the pin is...
What does INTCON.GIE do?
PIR1 and PIR2 contain...
Which register selects the RAM memory bank?
To read the state of a button wired to RB3 you use...
An SFR like TRISB differs from a GPR because...