Digital Signal Processing Reference
In-Depth Information
routine to your C source file. Also, add a call to this function in your
main
function preceding the line of code that calls the
test_lcd
function.
The code for
test_lcd
is shown in Figure 16.14. You will notice that this code
expects several constants to be defined. Add definitions for the following
constants in your
rpds_de_test.h
header file:
•
LCD_WR_COMMAND_REG = 0
•
LCD_WR_DATA_REG
=
2
The
main
function in your C source file should now be complete and look
similar to the code in Figure 16.15. Note that a few
printf
statements have been
added to provide the user with the program's status while executing.
alt_u32 test_lcd( void )
{
int i;
char message[17] = "Counting... ";
char done[12] = "Done! ";
/* Write a simple message on the first line. */
for( i = 0; i < 16; i++ ) {
IOWR( LCD_BASE, LCD_WR_DATA_REG, message[i] );
usleep(100);
}
/* Count along the bottom row */
/* Set Address */
IOWR( LCD_BASE, LCD_WR_COMMAND_REG, 0xC0 );
usleep(1000);
/* Display Count */
for( i = 0; i < 10; i++ ) {
IOWR( LCD_BASE, LCD_WR_DATA_REG, (char)(i+0x30) );
usleep(500000);
/* Wait 0.5 sec. */
}
/* Write "Done!" message on first line. */
/* Set Address */
IOWR( LCD_BASE, LCD_WR_COMMAND_REG, 0x80 );
usleep(1000);
/* Write data */
for( i = 0; i < 11; i++ ) {
IOWR( LCD_BASE, LCD_WR_DATA_REG, done[i] );
usleep(100);
}
return(0);
}
Figure 16.14
This is the code to test the LCD display.