Now it's time to return to the LCD driver application program again. We will start by running a simulation to find out how everything is connected. Let's use a really simple program.
int main(void) {
XStatus Status; // Initialize the GPIO component Status = XGpio_Initialize(&GpioLCD, GPIO_LCD_DEVICE_ID); if (Status != XST_SUCCESS) return XST_FAILURE; // Set the direction for all bits to be outputs XGpio_SetDataDirection(&GpioLCD, LCD_CHANNEL, 0x00); // Display one character XromWriteData(0x6,0x1);
return XST_SUCCESS; }
Here is the simulation waveform plot showing the GPIO bus connected to the LCD.
From this plot we can find out how the GPIO signals should be connected to the LCD driver. It was not the way we thought. Here is what it should look like.
Register Select 0:Instruction register during write 1:Data for read or write operation
1
AC17
LCD_RW
Read/Write Control 0:Write, LCD accepts data 1:Read, LCD presents data
2
AB17
LCD_DB7
Data Bus bit 7
3
AF12
LDC_DB6
Data Bus bit 6
4
AE12
LCD_DB5
Data Bus bit 5
5
AC10
LCD_DB4
Data Bus bit 4
6
AB10
Editing the user constraints file
We will change the pin mapping in the ETC_system.ucf file.
#### Module LCD_16x2 constraints
NET LCD_16x2_GPIO_IO_pin<0> LOC="AE13"; NET LCD_16x2_GPIO_IO_pin<0> IOSTANDARD = LVCMOS33; NET LCD_16x2_GPIO_IO_pin<0> PULLDOWN; NET LCD_16x2_GPIO_IO_pin<0> TIG; NET LCD_16x2_GPIO_IO_pin<1> LOC=AC17; NET LCD_16x2_GPIO_IO_pin<1> IOSTANDARD = LVCMOS33; NET LCD_16x2_GPIO_IO_pin<1> PULLDOWN; NET LCD_16x2_GPIO_IO_pin<1> TIG; NET LCD_16x2_GPIO_IO_pin<2> LOC=AB17; NET LCD_16x2_GPIO_IO_pin<2> IOSTANDARD = LVCMOS33; NET LCD_16x2_GPIO_IO_pin<2> PULLDOWN; NET LCD_16x2_GPIO_IO_pin<2> TIG; NET LCD_16x2_GPIO_IO_pin<3> LOC=AF12; NET LCD_16x2_GPIO_IO_pin<3> IOSTANDARD = LVCMOS33; NET LCD_16x2_GPIO_IO_pin<3> PULLDOWN; NET LCD_16x2_GPIO_IO_pin<3> TIG; NET LCD_16x2_GPIO_IO_pin<4> LOC=AE12; NET LCD_16x2_GPIO_IO_pin<4> IOSTANDARD = LVCMOS33; NET LCD_16x2_GPIO_IO_pin<4> PULLDOWN; NET LCD_16x2_GPIO_IO_pin<4> TIG; NET LCD_16x2_GPIO_IO_pin<5> LOC=AC10; NET LCD_16x2_GPIO_IO_pin<5> IOSTANDARD = LVCMOS33; NET LCD_16x2_GPIO_IO_pin<5> PULLDOWN; NET LCD_16x2_GPIO_IO_pin<5> TIG; NET LCD_16x2_GPIO_IO_pin<6> LOC=AB10; NET LCD_16x2_GPIO_IO_pin<6> IOSTANDARD = LVCMOS33; NET LCD_16x2_GPIO_IO_pin<6> PULLDOWN; NET LCD_16x2_GPIO_IO_pin<6> TIG;
Generate a new bitstream
We use the menu command Hardware->Generate Bitstream in Xilinx Platform Studio to generate a new bitstream.
Device configuration
We use the menu command Device Configuration->Download Bitstream to configure the FPGA.
Application program
Here is our "Hello World" program again.
int main(void) {
XStatus Status; // Initialize the GPIO component Status = XGpio_Initialize(&GpioLCD, GPIO_LCD_DEVICE_ID); if (Status != XST_SUCCESS) return XST_FAILURE; // Set the direction for all bits to be outputs XGpio_SetDataDirection(&GpioLCD,LCD_CHANNEL, 0x00);
We compile and link the program in Xilinx Platform Studio SDK and use the command Device Configuration->Program Hardware to load and execute the program. We keep staring at the LCD display and after a few seconds it displays: