Forum Discussion
Altera_Forum
Honored Contributor
16 years agoYour code should work. If not, I will check two things:
1. Did you connect the LCD external pins (not in SOPC, but in top VHDL file)? LCD_ON, -- Power ON/OFF LCD_BLON, -- Back Light ON/OFF if not, your LCD software may be working, but you will not see anything in the real LCD. 2. Maybe you need a initialization sequence for the LCD. ///// LCD control: ////////////////////////////////////////////////////// // From: http://www.altera.com/support/examples/nios2/exm-micro_mutex.html // ESC sequences: // From: http://www.isthe.com/chongo/tech/comp/ansi_escapes.html // ESC[#;#H Moves the cursor to line# , column# // ESC[2J Clear screen and home cursor // ESC[K Clear to end of line # define ESC_TOP_LEFT "[1;0H" # define ESC_BOTTOM_LEFT "[2;0H" # define LCD_CLR "[2J" # define LCD_CLR_LINE "[K" static unsigned char ESC = 0x1b; // Integer ASCII value of the ESC character void LCD_hello(void) { FILE* LCD; LCD = fopen ("/dev/lcd", "w"); if (LCD == NULL) { printf("LCD open failed\n"); } else { printf("LCD open succeeded\n"); fprintf(LCD, "%c%s", ESC, LCD_CLR); // Clears LCD fprintf(LCD, "LCD demo using\n"); fprintf(LCD, "Altera HAL in C"); } fclose (LCD); }