Thursday , March 30 2017
Home / Embedded Systems / Interface – LCD in 4 bit Mode: Part 3

Interface – LCD in 4 bit Mode: Part 3

Embedded applications are always developed on controllers whose resources are almost fully used in order to cut the cost of the product. This is done especially in applications that do not need any future expansions or a firmware updates. They are Make-it and Forget-it kind of applications. Most of the time, either the memory or the available pins are in demand. In some cases both memory and pin count are less.


The Character LCD in 8 bit mode uses 8 data lines and 3 control lines to display characters.  This kink of interface is costly in terms of pin usage. Most of the industrial applications use the LCD in 4 bit mode. The total data lines needed is reduced by half in this mode. I have already discussed this in on of my previous posts on the Theory behind the LCD modules. It is further possible to reduce the Port Pins required by asserting the R/W pin permanently LOW throughout the interface. By doing this we mean that the LCD will always be operated in Write mode and Read mode will not be use. This way another pin can be saved.

The interface of LCD in 4 bit mode without checking for busy flag can be little tricky and we have to give enough delays calls between data latch and next data write to insure that the LCD is never busy while a new data is written to it. This post will deal the programming of LCD in 4 bit mode with the R/W line of the LCD pulled low. Hence this interface will just use 6 pins of the interface.

Basic understanding:

The 8 bit data is split up into two chucks of 4 bits each. The higher nibble is sent first and then the lower nibble is sent to make one complete data transfer. Since each byte is transferred in two steps the speed of this method will theoretically be doubled. Also, we are not using the busy flag to monitor the state of the LCD so this introduced a further reduction the speed of the execution. We have use the command sheet to get commands that will make the LCD understand that we will be sending data in nibble format.


The connection is really simple and it is quit self explanatory. Here are some images to help understand the wiring better. There are a total of six pins (4 for data and 2 for command) that are connected to the PIC 18F4520 Microcontroller sitting over the ZIF (Zero Insertion Force) socket.


I’m using a development board that provides a breakout board for LCD displays. The Gnd, Vcc, Contrast, BL+, and BL- pins are internally connected to the power supply and potentiometer. So you will notice that I am not connecting anything to those pins.


In the above image you can see 7 wires that are connected to the Male Header pins. The R/W pin has to be grounded externally as it is not internally grounded. The white connector behind it is the 16 wire RMC connector that I am using as an extension cable form the LCD module.

LCD in 4 bit mode -  setup

Here is the entire setup. It shows how the R/W pin is held low throughout the interface. While designing PCB’s we can connect this permanently to ground or provide a jumper just in case we need to check the busy flag.


Here also we will be using the same functions. Only the lcd.c and lcd.h file have to be modified, the main.c has also been changed but the logic is the same. Also most of the function and how they behave has been discussed in my previous post, programming LCD in 8 bit mode. So I will not rehash them here and make this post lengthy.

Header File:

The delay function call will vary from one oscillator frequency to another. This code was tested for 20MHz oscillator. Make necessary changes so as to suit your system clock frequency or else this code may not work.

In the next post we will see how to display custom characters using the CG RAN (Character Generator RAM). Subscribe to our newsletters with your email and get updates on latest posts in your inbox.

About Siddharth

Siddharth is a Firmware Engineer, techie, and a movie-buff. His interests include, Programming, Embedded Systems, Linux, Robotics, CV, Carpentry and a lot more. At times, you could see some of his sunday projects converge on release quality. You get to know him on the following social channels.

Check Also


Interfacing 16×2 LCD with C2000 launchpad

  The C2000 Launchpad is an inexpensive evaluation module based on Piccolo family microcontrollers from …

  • Jorge

    Thanks man, ive been trying to get this to work, most of the guides or codes there dont tell you you have to put enable high and then low after each instruction, great tutorial.

Keep in touch with the current trends!
Did you like this article? Sign up and get our latest posts delivered to your inbox!
  We hate spam and never share your details.