LCD16x2 HD44780 Tutorial 3 – Display Address and Shifting


In this tutorial, I will explain about LCD16x2 DDRAM (Display Data RAM) addressing. The function of DDRAM is to store character that are displayed on LCD screen. HD44780 controller has 128 different addresses for DDRAM, although not all addresses have their own location on LCD screen. Only 80 display locations can be used to store characters. HD44780 is an LCD controller that can be used not just for size 16×2, but also for other sizes such as 16×4, 20×2, or 40×2. The display location for all LCD size is the same (80 location). The different is number of location that can displayed on screen. For example, on size 16×2, there is only 32 location, but other locations still can be used to store characters, although not displayed. To displayed that, we can shift the display to the right or to the left. This is the address locations of DDRAM that displayed on LCD16x2 whenever the LCD is powered up.

LCD address

When we set the DDRAM address, we also set the LCD cursor. The (0, 0) (column, row) location on the LCD screen is at address 0x00 and (0,1) location is on address 0x40. In fact, we can imagine that the other addresses that not displayed on 16×2 screen is like this:

LCD address all

From the picture above, if you noticed, there are missing addresses from 0x28 to 0x3F and 0x68 to 0x7F that can’t be use to store characters. Therefore only 80 locations of 128 addresses that can be used. From 80 locations, we can use display shift, to show locations that not show on LCD screen (on LCD screen, only 32 location are showed). We can do an experiment to show this LCD behavior.

LCD16x2 Shifting

First step, to set the LCD cursor/DDRAM address we can use instruction from the table on previous post. The instruction is 0x80 + address. So, if we want to set the DDRAM to the location 0x40, we must send 0xC0 or 0b11000000. Don’t forget to set RS to LOW and give EN pulse after that. After that, we will put a character on each location of the LCD screen boundary like this:

LCD address shift

To shift the display, we can use instruction 0x18 for left scroll or 0xC0 for right scroll. On each EN pulse, the display will be shifted one location. It is important to note that this scrolling is not move the characters to new DDRAM address locations. It just like move the whole addresses block left or right “under” the display screen. The movement of display shift is a complete rotation of display location. Try to move the display to the left or to the right until one rotation is completed, so you can see the result is same as showed on figure above.

If the display locations are not shifted back to original position, then address 0x00 will no longer be at the left-hand side of the screen. To get back, we can use the cursor home instruction 0x02 to go back to address 0x00 and also shift the address 0x00 to left-hand side of the screen. The clear display instruction does the same as cursor home, but also clears all the characters from DDRAM. We can also shift the cursor/DDRAM address by using 0x10 for shift cursor left and 0x14 for shift cursor right. Move cursor command also move the DDRAM/display address location.

Go to the part 4 of the tutorial.

Share this:

Leave a Reply

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