Why does the initialization code for a 20x4 LCD specify 2-line mode? Source: crystalfontz.com

FAQ: Why does the initialization code for a 20×4 LCD specify 2-line mode?

When working with a 20×4 character LCD, you might be surprised to see the controller set to 2-line mode:

Write_To_LCD(COMMAND,0x38); //SET 2 LINE,5*8 FONT

Why would a 4-line LCD’s controller be set to 2-line mode?

It has to do with the way the LCD glass is laid out. Essentially the display is the right and left halves of a 40×2 mapped to the top and bottom of a 20×4.

Here is a diagram to explain:
(click on the image for full-size view)

Why does the initialization code for a 20x4 LCD specify 2-line mode? Source: crystalfontz.com

 

The key is the address map for the display, which is included in the display’s datasheet. The address map shown above is typical, but not all displays use this exact map.

Be sure to check your display’s datasheet to verify its address map.

Need Additional Help?

If you have any questions about initialization code or how to power up any of our LCD displays, please contact our knowledgeable and friendly support staff by email, phone, or chat.