4 Bit LCD interfacing and programming with PIC Microcontroller

LCD displays operate in two modes 4 bit and 8 bit mode. We all might have been familiar with 8 bit mode which is used widely in several systems. But 4 bit mode is something which many of us is not aware of. This mode has some advantages over the 8 bit mode out of which reduction of dedicated data pins is most important. This tutorial will teach you 4 bit LCD interfacing in 4 bit with your controller as well as programming it.4 Bit LCD interfacing and programming with PIC Microcontroller

WHAT IS 4 BIT MODE:

We all knew that LCD consists of 8 data pins D0-D7 to receive the data and commands from the Microcontroller. However when developing a complex systems dedicating a complete port i.e 8 pins might be a drawback. To overcome this the LCD controller is capable of running in dual modes 8 bit and 4 bit mode.

8 Bit mode is a normal mode which uses 8 data lines, rs and enable for lcd functioning, see programming LCD in 8 bit mode. However in 4 bit mode only 4 lines D4-D7, along with RS,RW and EN pins are used. This will save us 4 pins of our controller which we might employ it for other purpose.

In 4 Bit mode the data bytes are sliced into two four bits and are transferred in the form of  a nibble. And the rest of the pin functions such as RS,RW and EN remains same. The above design illustrates the connection diagram of a 16×2 LCD with PIC microcontroller in 4 bit mode.

INITIALIZING THE LCD:

The first step in coding the LCD is initializing the LCD connected by giving the commands as input through the data line D4-D7 in the fom of Nibbles. For initializing the LCD following a specific reset sequence should be given and then initialized to follow the 4 bit mode.

  1. Place the byte in D4-D7 pins of LCD and set the EN pin to high and then make it low with time delay of 10ms between them.
  2. Send 28H command to use 2 lines 5×7 matrix in 4 bit mode.
  3. Send 0FH for making the LCD,cursor and Cursor blinking ON.
  4. Send 06H for incrementing cursor position.
  5. Finally 01 and 02 for clearing screen and returning home.

Schematic 4 Bit LCD interfacing and programming with PIC Microcontroller

DATA/COMMAND TRANSMISSION TO THE LCD:

The data transmission to a LCD must be performed by means of assigning logic states to three pins RS and E. R/W pin is not needed so we can ground it as shown in the schematic diagram. The data is send to the module by following these steps.

  1. RS pin should be high to convey LCD a data transmission is going to take place.
  2. Place the Upper nibble in the lower four bits of Port 2 by means of bit shifting and mask the upper four bits.
  3. Pulse En pin from high to low with certain time delay for transmission to complete.
  4. Now place the lower nibble and mask the rest of the bits, then repeat step

For more detail: 4 Bit LCD interfacing and programming with PIC Microcontroller

 

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter