54 www.xilinx.com Spartan-3A/3AN Starter Kit Board User GuideUG334 (v1.0) May 28, 2007Chapter 5: Character LCD Screen RPower-On InitializationThe initialization sequence first establishes that the FPGA application wishes to use thefour-bit data interface to the LCD as follows:1. Wait 15 ms or longer, although the display is generally ready when the FPGA finishesconfiguration. The 15 ms interval is 750,000 clock cycles at 50 MHz.2. Write LCD_DB<7:4> = 0x3, and pulse LCD_E High for 12 clock cycles.3. Wait 4.1 ms or longer, which is 205,000 clock cycles at 50 MHz.4. Write LCD_DB<7:4> = 0x3, and pulse LCD_E High for 12 clock cycles.5. Wait 100 μs or longer, which is 5,000 clock cycles at 50 MHz.6. Write LCD_DB<7:4> = 0x3, and pulse LCD_E High for 12 clock cycles.7. Wait 40 μs or longer, which is 2,000 clock cycles at 50 MHz.8. Write LCD_DB<7:4> = 0x2, and pulse LCD_E High for 12 clock cycles.9. Wait 40 μs or longer, which is 2,000 clock cycles at 50 MHz.Display ConfigurationAfter the power-on initialization is completed, the four-bit interface is established. Thenext part of the sequence configures the display:1. Issue a Function Set command, 0x28, to configure the display for operation on theSpartan-3A/3AN Starter Kit board.2. Issue an Entry Mode Set command, 0x06, to set the display to automatically incrementthe address pointer.3. Issue a Display On/Off command, 0x0C to turn the display on and disable the cursorand blinking.4. Finally, issue a Clear Display command. Allow at least 1.64 ms (82,000 clock cycles)after issuing this command.Writing Data to the DisplayTo write data to the display, specify the start address, followed by one or more data values.Before writing any data, issue a Set DD RAM Address command to specify the initialseven-bit address in the DD RAM. See Figure 5-3 for DD RAM locations.Write data to the display using a Write Data to CG RAM or DD RAM command. The eight-bit data value represents the look-up address into the CG ROM or CG RAM, shown inFigure 5-4. The stored bitmap in the CG ROM or CG RAM drives the 5 x 8 dot matrix torepresent the associated character.If the address counter is configured to auto-increment, as described earlier, the applicationcan sequentially write multiple character codes, and each character is automatically storedand displayed in the next available location.Continuing to write characters, however, eventually falls off the end of the first displayline. The additional characters do not automatically appear on the second line because theDD RAM map is not consecutive from the first line to the second.