Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12589 Discussions

NIOS II + Character LCD + DE0 Nano = Problem!

Altera_Forum
Honored Contributor II
1,642 Views

Hi all, 

I have spent my entire weekend trying working on the character LCD module provided as a display peripheral with NIOS II, and i am going nowhere with it!  

 

Here is my situation; 

SOPC build using NIOSII/f cpu, and character LCD, SDRAM, sysid, jtag_uart, and other few peripherals like led and stuff. 

 

I assigned pins for my LCD as following; 

set_location_assignment PIN_F13 -to LCD_RS 

set_location_assignment PIN_T15 -to LCD_E 

set_location_assignment PIN_T13 -to LCD_DATA[0] 

set_location_assignment PIN_T14 -to LCD_DATA[1] 

set_location_assignment PIN_T12 -to LCD_DATA[2] 

set_location_assignment PIN_R13 -to LCD_DATA[3] 

set_location_assignment PIN_T11 -to LCD_DATA[4] 

set_location_assignment PIN_R12 -to LCD_DATA[5] 

set_location_assignment PIN_R11 -to LCD_DATA[6] 

set_location_assignment PIN_T10 -to LCD_DATA[7] 

 

I have grounded the LCD_RW pin as i dont plan on reading anything from the LCD. 

 

Following is my main.c; 

#include <stdio.h> # include "system.h" # include "altera_avalon_pio_regs.h" # include "altera_avalon_lcd_16207_regs.h" # include "altera_avalon_lcd_16207.h" int main(){ char ch = '\0'; FILE *lcd_d = 0; lcd_d = fopen(LCD_DISPLAY_NAME, "w"); printf("LCD & Keypad Test!\n"); //altera_avalon_lcd_16207_init(LCD_DISPLAY_BASE); printf("Address of LCD: %s\n", LCD_DISPLAY_NAME); while(1){ ch = kbd_getc(); usleep(9); if(ch != 0){ printf("%c ", ch); fprintf(lcd_d, "Hello LCD"); } } return (0); } 

 

I have all the stderr, stdin and stdout pointed to jtag_uart. I tried pointing it to LCD, but still no luck 

I dont have Reduced Driver selected nor do i have reduced C library selected. 

In my BSP, i can see the driver for LCD. 

in the alt_sys_init.c file in my BSP project folder, i can also see the altera_avalon_lcd_16207_init(LCD_NAME, lcd_name) is called. And i am guessing that this initializes my LCD.  

altera_avalon_lcd_16207.c is also included in my system.  

 

So when i print fprintf(lcd_d, "Hello World"); it prints nothing. It is not even initializing my LCD. 

 

Any help would be greatly appreciated! I have spent way too much time on this and i know i am missing some stupid thing! 

 

Thank you 

PK
0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
644 Views

Please note that my ch = kbd_getc() function is working properly as it successfully prints the value from my keypad to stdout;

0 Kudos
Altera_Forum
Honored Contributor II
644 Views

Personally I wouldn't try to debug hardware using printf() - I'd test using the low level hardware interface. 

 

You might have issues because printf() could be buffering output.
0 Kudos
Altera_Forum
Honored Contributor II
644 Views

 

--- Quote Start ---  

Personally I wouldn't try to debug hardware using printf() 

--- Quote End ---  

 

 

i am not trying to debug, I am trying to print some numerical values to the LCD, and maybe some Alphabetical.  

 

LCD will act as an output medium for the user. The LCD will eventually have a menu, and the user can input their options using a 4X4, keypad!
0 Kudos
Altera_Forum
Honored Contributor II
644 Views

Well, it doesn't work - so you are trying to debug it! 

 

If the LCD panel has it's own character generator and display hardware - so presents just an 8-bit ascii (ish) interface to the outside world, then your LCD_DATA[0-7] are presumably the 8-bit data and are connected to an Avalon slave for PIO access from the Nios cpu. 

In which case doing uncached writes directly to the PIO addresses would be a much better place to check things. 

 

On the other hand, the 8 data bits might be raw pixel data (for multiple pixels), and you'll need some logic to repeatedy copy the frame image out to the LCD panel. In this case you'll need your own character generator (etc). 

 

In either case I wouldn't consider using printf().
0 Kudos
Altera_Forum
Honored Contributor II
644 Views

Alright, i'll took your advice and i went away from printf.  

 

I tried writing to lcd using fwrite() or fputc() and i am still not having any luck with it. I dont think that my program is initializing the LCD. 

 

One of my friends said that it might be because i am not using an OPTREX LCD that regular terasic board comes with. Since i am using a DE0-Nano board, i used a LUMEX LCD that i had sitting around. I really dont think this is the case, any opinions?
0 Kudos
Altera_Forum
Honored Contributor II
644 Views

I meant dont use any of the stdio functions.....

0 Kudos
Altera_Forum
Honored Contributor II
644 Views

I figured out the problem.  

The problem was with the LCD_RW pin. Because i thought i never want to read from the LCD, i had the pin grounded, but once i assigned LCD_RW to pin_out, the whole thing worked like a charm,  

 

All the fprintf, fwrite or fputc function works now! 

 

Thanks for all your help!
0 Kudos
Reply