Forum Discussion
Altera_Forum
Honored Contributor
22 years agoNios II LCD Driver
Greetings. Quite simply my LCD doesn't "work" with Nios II. It has and does work with Nios I.
From the simple "web server" default reference design where the display should show something like: "Nios II, IP address: xxx.xxx.xxx.xxx" (or equivalent), to the count_binary reference design, to writing my own (quick) code: FILE *fp_LCD=0;
fp_LCD = fopen(LCD_DISPLAY_NAME,"w"); // open LCD for write
if(fp_LCD==0)
printf("\nError Opening %s\n\n",LCD_DISPLAY_NAME);
else
{
printf("LCD opened, ready for access!\n");
fprintf(fp_LCD,"Hello LCD");
fclose(fp_LCD);
} Does anyone have their LCD working? Any special tricks? FYI, I have the Nios-devkit-1C20, and I have upgraded the FLASH to use the factory_recovery for Nios II... Thanks, -Terry19 Replies
- Altera_Forum
Honored Contributor
Have you got the compact flash card plugged in? It doesn't work with Nios II if the compact flash card is plugged in, this is barely mentioned in a readme text file somewhere!
Adrian - Altera_Forum
Honored Contributor
How on earth did you find this out!!!!!!
Perhaps I need to do more reading! Thanks, it worked! Regards, -Terry - Altera_Forum
Honored Contributor
It's one of those things that if you know it, you know it.
Sorry, Where could we have documented this to make more people see it? I ask so we can doc it somewhere better for the next release. - Altera_Forum
Honored Contributor
Kerri:
I see that it is posted in the documents/errata.txt file. I should have read through this before beating my head against the wall! FYI, I searched the "Nios II Software Developer's Handbook", then checked the "Nios II Processor Reference Handbook" under Section II Peripheral Support. I see that the SDRAM Controller, DMA, PIO, Timer, JTAG UART, UART, SPI, EPCS, CFI, and SysID peripherals are nicely defined. Then again, since the LCD is nothing more than a PIO, it doesn't have to be included here... After checking through those two docs, I referred to the "Nios II Device Drivers" library in my IDE, and browsed to the altera_avalon_lcd_16207 directory. I briefly looked through the .c and .h files but didn't have much luck... It appeared to me that it "should" work. I am not really answering your question here so let's try this: In short, the best place to start looking should have been the readme.txt & errata.txt, but I figured I had something wrong and that it wasn't really errata at all. Having said that, I'm thankful for the Nios Forum because someone is bound to know the answer! Cheers, -Terry - Altera_Forum
Honored Contributor
I'll give that feedback to the doc people.
Note that with Reader you can do a search (rather than a find) and it will search all the pdf's in any directory. Wouldn't have helped you here (since the errata and readme are in txt format), but might be helpful other times. - Altera_Forum
Honored Contributor
All: I have gotten the LCD working correctly using fprintf; but it appears as though I have found a "bug"
Here is some test code based on the Hello_World reference
After compiling and downloading, the code appeared on the LCD, displaying the first 16 characters. Kind of made sense until I looked through the lcd HAL driver and see that the text should scroll. I won't get into details, but I played around with the code for hours, comparing to the count_binary.c reference design which works. I came across this: The alt_sys_init.c file that gets created for my hello_world is slightly different than the count_binary.c, not suprising really, but check this out:#include <stdio.h># include "system.h" int main() { FILE *fp_LCD=0; printf("Hello from Nios II!\n"); fp_LCD = fopen(LCD_DISPLAY_NAME,"w"); // open LCD for write if(fp_LCD==0) printf("\nError Opening %s\n\n",LCD_DISPLAY_NAME); else { printf("LCD opened, ready for access\n"); fprintf(fp_LCD,"This message should scroll across the screen... "); } return 0; }
By default, the first line is enabled and the last line doesn't exist. This doesn't scroll the text. By commenting out the first line and moving the driver initilization to the end (as shown), the text scrolls!!! I haven't gone through the trouble of seeing which driver is interferring with the LCD, but I thought you may be interested! Regards, -Terryvoid alt_sys_init( void ) { //ALTERA_AVALON_LCD_16207_INIT( LCD_DISPLAY, lcd_display ); ALTERA_AVALON_DMA_INIT( DMA, dma ); ALTERA_AVALON_EPCS_FLASH_CONTROLLER_INIT( EPCS_CONTROLLER, epcs_controller ); ALTERA_AVALON_CFI_FLASH_INIT( EXT_FLASH, ext_flash ); ALTERA_AVALON_TIMER_INIT( SYS_CLK_TIMER, sys_clk_timer ); ALTERA_AVALON_TIMER_INIT( HIGH_RES_TIMER, high_res_timer ); ALTERA_AVALON_JTAG_UART_INIT( JTAG_UART, jtag_uart ); ALTERA_AVALON_LAN91C111_INIT( LAN91C111, lan91c111 ); ALTERA_AVALON_SYSID_INIT( SYSID, sysid ); ALTERA_AVALON_UART_INIT( UART1, uart1 ); ALTERA_AVALON_LCD_16207_INIT( LCD_DISPLAY, lcd_display ); } - Altera_Forum
Honored Contributor
hi tjd,
Sorry to bring this topic back up. But the work around you came up with, did it work with the compact flash card inserted in the dev kit? My design involves using a compact flash card to store data which is then fed into the sdram. I am trying to upgrade to a nios2 system right now, but if I cannot use the lcd with the cf card inserted, it might pose a problem. The design i have currently can be used as a stand alone product or attached to a pc, but requires the lcd in stand alone mode. thanx, -Quan - Altera_Forum
Honored Contributor
Hi Quan,
Funny you should ask... Short answer - No, I haven't got both the CF and the LCD working together. Verbose answer: I was trying to get the LCD to work with the compact flash card plugged in, but had little luck. I see that the chip select lines of the Compact Flash are not "disabled" (ie pulled high), nor is the CF_POWER line "disabled". (pulled low) I tried to make a change but got hung up on a problem with downloading my ref design. It seems that I can't mod the full_featured ref design and successfully download it. I suspect this is a silly bug on my part that I haven't had time to look further into... Side note: Has anyone else experienced this? Doesn't really help, but may provide some insight... -Terry - Altera_Forum
Honored Contributor
Strictly an FYI, re:
<div class='quotetop'>QUOTE </div> --- Quote Start --- I tried to make a change but got hung up on a problem with downloading my ref design. It seems that I can't mod the full_featured ref design and successfully download it. I suspect this is a silly bug on my part that I haven't had time to look further into... Side note: Has anyone else experienced this?[/b] --- Quote End --- Turns the PC I am using isn't properly licensed for Nios/Nios II. As a result, I needed to program with the full_featured_time_limited.sof rather than the full_featured.sof file. I will advise if/when I make headway. Cheers, -Terry - Altera_Forum
Honored Contributor
Hi Terry,
I haven't tried the full_featured ref design of the nios II yet. I am still only using the nios I but if these are problems not cannot be fixed yet, then i will not do the full upgrade path. There is the legacy upgrade path to enter into the nios II realm, I wonder if the legacy lcd drivers will still work with the nios II? I'll have to try it in the next couple of weeks. Please update if you find a fix on this, and i will do the same. thanx, -Quan