Optrex 16207 LCD Controller Core with Avalon Interface

Core Overview

The Optrex 16207 LCD Controller Core with Avalon® Interface (“the LCD controller”) provides the hardware interface and software driver required for a Nios® II processor to display characters on an Optrex 16207 (or equivalent) 16x2-character LCD panel. Device drivers are provided in the HAL system library for the Nios II processor. Nios II programs access the LCD controller as a character mode device using ANSI C standard-library routines, such as printf(). The LCD controller is SOPC Builder-ready, and integrates easily into any SOPC Builder-generated system.

The Nios II Embedded Design Suite (EDS) includes an Optrex LCD module and provide several ready-made example designs that display text on the Optrex 16207 via the LCD controller. For details on the Optrex 16207 LCD module, see the manufacturer's Dot Matrix Character LCD Module User’s Manual available at http://www.optrex.com.

Functional Description

The LCD controller hardware consists of two user-visible components:

Eleven signals that connect to pins on the Optrex 16207 LCD panel — These signals are defined in the Optrex 16207 data sheet.

An Avalon Memory-Mapped (Avalon-MM) slave interface that provides access to 4 registers — The HAL device drivers make it unnecessary for users to access the registers directly.

Figure 1 shows a block diagram of the LCD controller core.


LCD Controller Block Diagram

Instantiating the Core in SOPC Builder

In SOPC Builder, the LCD controller component has the name Character LCD (16x2, Optrex 16207). The LCD controller does not have any user-configurable settings. The only choice to make in SOPC Builder is whether or not to add an LCD controller to the system. For each LCD controller included in the system, the top-level system module includes the 11 signals that connect to the LCD module.

HAL System Library Support

Altera provides HAL system library drivers for the Nios II processor that enable you to access the LCD controller using the ANSI C standard library functions. The Altera-provided drivers integrate into the HAL system library for Nios II systems. The LCD driver is a standard character-mode device, as described in the Nios II Software Developer's Handbook. Therefore, using printf() is the easiest way to write characters to the display.

The LCD driver requires that the HAL system library include the system clock driver.

Displaying Characters on the LCD

The driver implements VT100 terminal-like behavior on a miniature scale for the 16x2 screen. Characters written to the LCD controller are stored to an 80-column x 2-row buffer maintained by the driver. As characters are written, the cursor position is updated. Visible characters move the cursor position to the right. Any visible characters written to the right of the buffer are discarded. The line feed character (\n) moves the cursor down one line and to the left-most column.

The buffer is scrolled up as soon as a printable character is written onto the line below the bottom of the buffer. Rows do not scroll as soon as the cursor moves down to allow the maximum useful information in the buffer to be displayed.

If the visible characters in the buffer will fit on the display, then all characters are displayed. If the buffer is wider than the display, then the display scrolls horizontally to display all the characters. Different lines scroll at different speeds, depending on the number of characters in each line of the buffer.

The LCD driver understands a small subset of ANSI and VT100 escape sequences that can be used to control the cursor position, and clear the display as shown in Table 8–1

Table 1. Escape Sequence Supported by the LCD Controller

Sequence Meaning
BS   (\b)Moves the cursor to the left by one character.
CR   (\r)Moves the cursor to the start of the current line.
LF   (\n)Moves the cursor to the start of the line and move it down one line.
ESC(  (\x1B)Starts a VT100 control sequence.
ESC  [   <y>   ;   <x>   HMoves the cursor to the y, x position specified – positions are counted from the top left which is 1;1.
ESC  [  K Clears from current cursor position to end of line.
ESC  [   2  JClears the whole screen..

The LCD controller is an output-only device. Therefore, attempts to read from it will return immediately indicating that no characters have been received.

The LCD controller drivers are not included in the system library when the Reduced device drivers option is enabled for the system library. If you want to use the LCD controller while using small drivers for other devices, then add the preprocessor option -DALT_USE_LCD_16207 to the preprocessor options.

Software Files

The LCD controller is accompanied by the following software files. These files define the low-level interface to the hardware and provide the HAL drivers. Application developers should not modify these files.

Interrupt Behavior

The LCD controller does not generate interrupts. However, the LCD driver's text scrolling feature relies on the HAL system clock driver, which uses interrupts for timing purposes.

Reference

Quartus II Version 7.0 Handbook Volume 5: Embedded Peripherals, (Chapter 8).
The document is available as a PDF.


Maintained by John Loomis, last updated 12 April 2007