LCD interfacing with ARM7 (LPC2148)- 4 bit mode


LCD is one for the most useful device. However it needs upto 11 GPIO pins for proper working. If we configure LCD to operate in 4 bit mode, we can  interface LCD using only 6 GPIO pins of micro-controller. In this article we will explain how to interface LCD in 4 bit but before that you must understand the basics of LCD from this tutorial.

Conversion from 8 bit to 4 bit

Let's assume that dataport of LCD has some initial values which are unknown and we have a 8 bit command cmd to be given to LCD.

Thus initially dataport= xxxx xxxx  and cmd= yyyy zzzz ( here yyyy is upper nibble of command and zzzz is lower nibble of the command)

As we need to send data in 4 bit mode we need to send data in two parts on D4-D7 of LCD Databus and we must keep initial values of D3-D0 as it is. So our final output must be xxxx yyyy and xxxx zzzz

In short we have two inputs

  1. dataport= xxxx xxxx &
  2. cmd=yyyy zzzz

We need two outputs

  1. output-1= yyyy xxxx &
  2. output-2= zzzz xxxx

In ARM7, operations performed by IOSET and IOCLR registers are bit wise operations which means we can SET/CLEAR individual pins of both the ports.

Now to obtain output-1, let's follow simple steps

First we need to clear D4-D7 of LCD. Now we need to set those pins in which we have 1 as per the part of command word yyyy.

Now to obtain output-2, let's follow simple steps

First we need to clear D4-D7 of LCD. Now we need to set those pins in which we have 1 as per the part of command word zzzz.

These steps can be easily understood in program.

Apart from this, we need minor changes in the code which we have used for 8 bit.

LCD has some default configurations which are 8 bit mode and increment after displaying data. If we want to modify any of this configuration (which we are changing here from 8 bit mode to 4 bit mode), we need to reset LCD. To reset the LCD, we have to give series of command as 0x33 (2 times) followed by 0x32.

Basic commands of LCD

Basic commands of LCD

Here is the list of basic commands for LCD.

From this list, it is clear that Function Set command for 4 bit mode, 2 line 5x7 dots LCD is 0x28 instead of 0x38 for 8 bit mode.

With these changes, we are good to go for LCD interfacing in 4 bit mode. Code and schematic for 4 bit are given in the respective sections of the site.

If you have any queries, feel free to Ask us here.

Please log in to view code.

You may also like...

Leave a Reply

Specify Facebook App ID and Secret in Super Socializer > Social Login section in admin panel for Facebook Login to work

Specify LinkedIn Client ID and Secret in Super Socializer > Social Login section in admin panel for LinkedIn Login to work

Your email address will not be published. Required fields are marked *