LCD Controller

The LCD Controller allows you to control the LCD screen on the DE2 board. It will recognize ASCII characters, and accepts various control signals to modify the way it functions and the position of the cursor.

DeviceLCD Controller
ConfigurationTwo 8-bit mapped registers
Input/OutputEither
Address Base0x10003050
Address Map Note that because the instruction and data registers are only 8 bits each, the address offset for the data register is only 1, not 4 like most other devices.
AddressR/WDescription
baseR/WInstruction
base+1R/WData
ReferencesAltera's Documentation of LCD Core
Detailed Documentation of LCD Controller (See page 14 for full list of instructions available)
DE2 Media Computer Manual (See section 4.4 for details.)


The LCD controller requires a control signal to change lines or the position of the cursor other than advancing with each character, rather than the ASCII codes.

Instruction bit 7 bits 6 to 0
Set cursor location 1 Address
Shift display left 0 0011000
Shift display right 0 0011100
Cursor off 0 0001100
Cursor blink on 0 0001111
Clear display 0 0000001


The address to which a character is written can be represented in the form (x,y) where x is the location on the line (0--15) and y is the row (0--1), in the following format:

bit 6 bits 5..0
y x


Further details can be found in the DE2 Media Computer manual and the other reference material linked above.

Assembly Example: Writing the letter "A" to position 10 in the first line, then moving the cursor to the second line

	movia r7, 0x10003050 /* r7 contains base address for LCD controller */

	/* Set cursor to point 10 */
	movi r3, 0x8a
	stbio r3,0(r7)
	
	movui r3, 65 /* ASCII code for A */
	stbio r3, 1(r7) /* Write the letter A */
	
	movui r3, 0xc0 /* Command for moving to the first bit of the second line */
	stbio r3, 0(r7) /* Send the command */

C Example: Write "Hello World" to the LCD Display


void displayTextLCD(char * text_ptr)
{
  	volatile char * LCD_display_ptr = (char *) 0x10003050;	// 16x2 character display

	while ( *(text_ptr) )
	{
		*(LCD_display_ptr + 1) = *(text_ptr);	// write to the LCD data register
		++text_ptr;
	}
}

int main()
{
	displayTextLCD("Hello, World!");
}