Summary of How to interface 16×2 LCD in 4-bit mode with PIC18F4550
This article explains interfacing a 16x2 LCD with the PIC18F4550 microcontroller in 4-bit mode to save controller pins. It details that only data pins D4-D7 are used, while control pins remain connected as in 8-bit mode. The text describes sending data in two nibbles (high then low) and provides specific Function Set instructions (0x20 and 0x28) for configuration. It also notes that power-up defaults to 8-bit mode, requiring special handling during initialization.
Parts used in the 16x2 LCD Interfacing Project:
- 16x2 character LCD
- PIC18F4550 microcontroller
- Data pins (D4-D7)
- Control pins (RS, RW, EN)
- PortB of PIC18F4550
The 16×2 character LCD can work in two modes, namely, 8-bit and 4-bit. These modes basically correspond to the number of data pins used in interfacing LCD. 8-bit mode uses all the data lines and has been explained in LCD interfacing with PIC18F4550. In 4-bit mode, only four data pins of LCD are connected to the controller. This mode, thus, saves four pins of the controller unlike 8-bit mode. The configuration and display method of LCD in 4-bit mode has been explained here.
The 8-bit mode of LCD interfacing with PIC has been explained earlier. In the 4-bit mode the (8-bit) data/command is sent in nibble (four bits) format to LCD. The higher nibble is sent first followed by the lower nibble. In 4-bit mode only four data pins (D4-D7) of LCD are connected to the controller. The control pins (RS, RW and EN) are connected the same way as in 8-bit mode. The connections of LCD with PIC18F4550 are shown in the adjoining circuit diagram. Please note that here only PortB is used to connect data lines as well as control lines unlike in 8-bit mode. Refer LCD interfacing with PIC in 8-bit mode.
|
Instruction
|
RS
|
RW
|
D7
|
D6
|
D5
|
D4
|
D3
|
D2
|
D1
|
D0
|
|
Function Set
|
0
|
0
|
0
|
0
|
1
|
DL
|
N
|
F
|
–
|
–
|
|
Value
|
DL
|
N
|
F
|
|
1
|
8 bit
|
2 lines
|
5×10 dots
|
|
0
|
4 bit
|
1 line
|
5×7 dots
|
- How many data pins are used in 4-bit mode?
Only four data pins (D4-D7) are connected to the controller. - What is the order of sending data in 4-bit mode?
The higher nibble is sent first followed by the lower nibble. - Which instruction selects the working modes of the LCD?
The Function Set instruction is used to select the working modes. - What is the Function Set value for 4-bit mode?
The value is 0x20 or [0010 0000]. - What is the Function Set value for 2-line 4-bit mode?
The value is 0x28 or [0010 1000]. - In which mode does the LCD remain when power is supplied?
The LCD remains in 8-bit mode when power is supplied. - Why is 4-bit mode preferred over 8-bit mode?
It saves four pins of the controller compared to 8-bit mode. - What happens if 0x20 is sent immediately after power up?
Only 0x02 is received because the lower nibble is not received on the four connected lines.
