Maria Montero

How to connect the Mojo v3 FPGA board with an LCD module …

This article will discuss the details of the interface of a basic 16 × 2 LCD module with an FPGA.

In this tutorial, we will use Verilog HDL to design a digital circuit that interfaces with common LCD modules that are based on the HD44780 LCD driver / controller chip. The Mojo V3 FPGA board will be used to implement the design. The LCD module used in this article is the 1602A display.

HD44780 Compatible LCD Modules

In a previous article, we discussed the details of LCD modules using the HD44780 LCD driver / controller chip. The pinout for these LCD modules is shown in Figure 1.

Figure 1. Image courtesy of AAC.

As you can see, there are three control pins (RS, R / W, and E) along with eight data pins (DB7 to DB0). For a write operation, we need to apply the appropriate voltages to these pins, as shown in the timing diagram in Figure 2 below.

Figure 2. Courtesy of HITACHI.

The different delay values ​​from the above timing diagram are given in the following table:

Table 1. Courtesy of HITACHI.

There are several instructions that can be used to configure the LCD module. You can find a complete list of these instructions on page 24 of this data sheet. Some important instructions are listed below.

Table 2

Design Building Blocks: Route 1

We want to display the message “HELLO WORLD!” On the LCD screen. Let’s see what building blocks our digital system needs to communicate with the LCD module. We need a ROM to store the ASCII code for the message characters. As shown in Figure 3, the ROM output will be connected to the eight data pins of the LCD module.

figure 3

The message “HELLO WORLD!” It has 12 characters, and we can use a 12 ✕ 8 bit ROM to store the message. However, let’s consider a 16 ✕ 8-bit ROM for the message, so that we can display messages of up to 16 characters (the length of the first row of the LCD screen).

You may wonder why the figure above shows a 20 ✕ 8-bit ROM if our message has a maximum length of 16 characters. These additional four bytes will be used to store data related to the LCD screen instructions that allow us to configure the module. For example, as indicated in Table 2, we can apply hexadecimal value 0x38 to the LCD data pins to specify that the LCD module should receive / send data in 8-bit lengths. Like character codes, command hexadecimal values ​​are applied to data pins, therefore we can store them in the same ROM.

In this article, we will use four commands (0x38, 0x06, 0x0C, and 0x01) to configure the LCD. You can find a brief description of these commands in Table 2. For a detailed explanation, please refer to this article. So we have a 20 ✕ 8 bit ROM, where the first four bytes are 0x38, 0x06, 0x0C, and 0x01. The next 16 bytes store the ASCII code for our message.

Taking into account the timing diagram in Figure 2, we note that the data applied to DB7-DB0 must not change for a certain time for the LCD screen to be able to read it correctly. Therefore, as shown in Figure 3, we need a set of D-type (DFF) flip-flops to keep the address of the ROM (and consequently DB7-DB0) constant over a period of time. After the LCD screen reads the data, we will need to increase the address value by one to apply the next character / command to the LCD screen. Therefore, as shown in Figure 4, a multiplexer and an incrementer must be placed before the DFFs.