Summary of How to interface LEDs with PIC18F4550 Microcontroller
This article introduces the basic I/O operations of the PIC18F4550 microcontroller, focusing on configuring ports to blink LEDs in an alternating pattern. It details the 35 I/O pins distributed across five ports (A–E) and explains the roles of TRISx, PORTx, and LATx registers for input/output control. The text highlights pin multiplexing differences compared to 8051 microcontrollers and provides specific register bit mappings for each port, noting hardware limitations such as missing bits in PORTA and PORTC.
Parts used in the PIC18F4550 LED Blinking Project:
- PIC18F4550 Microcontroller
- LEDs
- PORTA
- PORTB
- PORTC
- PORTD
- PORTE
- TRISx Register
- PORTx Register
- LATx Register
It is necessary to understand basic I/O operations of PIC18F4550 before dealing with its complexities. This article presents a way to take simple output from a PIC microcontroller. This learning would also help in interfacing of external devices with the controller. Here the output from the microcontroller is taken on a set of LEDs which are made to blink in an alternate fashion.
PIC18F4550 has a total of 35 I/O (input-output) pins which are distributed among 5 Ports. The following table shows the names and numbers of I/O pins of these 5 ports:
|
Port Name
|
Number of Pins
|
Pins
|
|
PORTA
|
7
|
RA0-RA6
|
|
PORTB
|
8
|
RB0-RB7
|
|
PORTC
|
7
|
RC0-RC2, RC4-RC7
|
|
PORTD
|
8
|
RD0-RD7
|
|
PORTE
|
4
|
RE0-RE3
|
|
Bit 7
|
Bit 6
|
Bit 5
|
Bit 4
|
Bit 3
|
Bit 2
|
Bit 1
|
Bit 0
|
|
|
TRISA
|
–
|
TRISA6
|
TRISA5
|
TRISA4
|
TRISA3
|
TRISA2
|
TRISA1
|
TRISA0
|
|
PORTA
|
–
|
RA6
|
RA5
|
RA4
|
RA3
|
RA2
|
RA1
|
RA0
|
|
LATA
|
–
|
LATA6
|
LATA5
|
LATA4
|
LATA3
|
LATA2
|
LATA1
|
LATA0
|
|
Bit 7
|
Bit 6
|
Bit 5
|
Bit 4
|
Bit 3
|
Bit 2
|
Bit 1
|
Bit 0
|
|
|
TRISB
|
TRISB7
|
TRISB6
|
TRISB5
|
TRISB4
|
TRISB3
|
TRISB2
|
TRISB1
|
TRISB0
|
|
PORTB
|
RB7
|
RB6
|
RB5
|
RB4
|
RB3
|
RB2
|
RB1
|
RB0
|
|
LATB
|
LATB7
|
LATB6
|
LATB5
|
LATB4
|
LATB3
|
LATB2
|
LATB1
|
LATB0
|
- How many I/O pins does the PIC18F4550 have?
The PIC18F4550 has a total of 35 I/O pins. - What are the three 8-bit registers used to configure a Port for general I/O purpose?
The three registers are TRISx, PORTx, and LATx. - Which register stores the data sent to external hardware as output?
The LATx register is the output latch register where output data is stored. - How many pins does PORTA have?
PortA has 7 pins which can be used as both input and output pins. - Can Pins 4 and 5 of PORTC be used as output pins?
No, Pins 4 and 5 in PortC can only be used as input pins. - What happens to the 8th bit in the registers for PORTA?
The 8th bit is internally masked in all three registers for PORTA. - Does the PIC18F4550 have most of its port pins serving a single function like the AT89C51?
No, the port pins of the PIC18F4550 are multiplexed to serve more than one purpose. - Where is the input signal read from when a pin is configured as input?
The input signal from an external source is read from the PORTx register.
