Altera_Forum
Honored Contributor
16 years agoProblem with character LCD on Cyclone III FPGA Development Kit
Hello,
I am writing because I have a problem with the character LCD on Cyclone III FPGA Development Kit. I cannot write anything on it, I always have the first line completely black, and the second line completely empty. I read carefully the documentation and previous posts on the forum about similar problem, and I know that there is an error on the Altera documentation about the enable pin (AC24 instead of AB24). So, I do not understand why that does not work. Attaching, I put the schematic file of quartus, the system build with sopc builder, and the properties of the nios project. I first try with the following simple program :# include <stdio.h> // Needed for printf# include "system.h"# include "altera_avalon_pio_regs.h"
int main (void)
{
IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0x35); // Display a known value on leds
printf("Hello\n");
IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0xA2); // Display a known value on leds
while(1);
}
My leds display well 0xA2 at the end, but nothing on LCD. After I try using fprintf, with the following program : # include <stdio.h> // Needed for printf# include <unistd.h> // Needed for usleep# include "system.h"# include "altera_avalon_pio_regs.h"
int main (void)
{
int nbChar;
FILE * lcd;
lcd = fopen(LCD_NAME, "w"); // Open the LCD device
if (lcd == NULL) // Test the success of the file opening by displaying value on leds
IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0x86);
else
IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0x3C);
usleep(5000000); // Pause 5s to read the value on leds
nbChar = fprintf(lcd, "Hello\n"); // Printf something on LCD and get the number of characters written
IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0xFF & (nbChar >> 24)); // Display on leds the value returned by fprintf (1st 8 bits)
usleep(5000000); // Pause 5s to read the value on leds
IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0xFF & (nbChar >> 16)); // Display on leds the value returned by fprintf (2nd 8 bits)
usleep(5000000); // Pause 5s to read the value on leds
IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0xFF & (nbChar >> 8)); // Display on leds the value returned by fprintf (3rd 8 bits)
usleep(5000000); // Pause 5s to read the value on leds
IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0xFF & (nbChar >> 0)); // Display on leds the value returned by fprintf (4th 8 bits)
usleep(5000000); // Pause 5s to read the value on leds
while(1);
}
The opening of the file succeed since I see 0x3C on the leds, and the value returned by the fprintf function is well 6. But I still have nothing on LCD. If someone have an idea of the cause of this problem, because I really don't see what it can be. Thanks in advance Jérôme