zoukankan      html  css  js  c++  java
  • [FPGA][NiosII]内置LCD控制器使用心得(转)

    [FPGA][NiosII]内置LCD控制器使用心得
     

    学习niosII很好玩,特别是在解决问题的时候

    实验3 NiosII 内置字符型LCD控制器实验

    实验平台:Altera CycloneII EP2C8 核心板

    本实验使用如下IP:NiosII软核、SDRAM控制器、字符型LCD控制器、JTAGUART(调试很方便)、PLL锁相环

    源程序:使用Nios IDE内置Hello World模板修改得到(其他模板可能会出问题)

    ============================================

    #include <stdio.h>
    #include "system.h"

    int main()
    {
    FILE *fp_LCD=0;

    printf("Hello from Nios II!\n");    
        
    fp_LCD = fopen("/dev/lcd_16207_0","w");   // open LCD for write

    if(fp_LCD==0)
       printf("\nError Opening %s\n\n");
    else
       {
       printf("LCD opened, ready for access\n");
       fprintf(fp_LCD,"This message should scroll across the screen... ");
       }

    return 0;
    }

    ============================================

    常见问题:

    1)"dev/lcd_16207_0" 请参考system.h里面自行修改,默认是这个,如果改了名字就变了

    2)我之前使用的源程序无法使用,fopen值为0,如下,应该也是正确的,很怪异,可能基于的模板不同,自己建立的空模板连system.h都打不开,还是很新手啊。

    =========================================

    #include "system.h"
    #include <stdio.h>
    #include <unistd.h>
    #include <string.h>
    #include <io.h>

    int main (void)
    {
    FILE *lcd;

    lcd = fopen("/dev/lcd_16207_0","w");
    if (lcd == 0)
    printf("lcd not ready...\n");
    else
    {
        printf("lcd ready...\n");
        fprintf(lcd, "hello lcd...\n");
    }

    fclose(lcd);
    printf("can you see anything?");

    return 0;
    }

    ==========================================

    3)国内基本没有像样的sopc论坛,nios资源太少太少,推荐http://www.niosforum.com/

    源程序是里面提供并建议使用hello world模板。

    4)1602是可以显示了,但是还有一些问题,一句话显示的不完全

    原作者也提到了,可能fprintf函数只能一次显示16个字母

    以下是原文:

    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:

    CODE
    void 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 );
    }



    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,
    -Terry

    链接地址

    http://forum.niosforum.com/forum/index.php?showtopic=92&hl=lcd

  • 相关阅读:
    Ext JS 6开发实例(三) :主界面设计
    Ext JS 6开发实例(二) :使用CMD创建应用程序
    文件夹或者文件比对工具 Beyond Compare
    LIS问题(DP解法)---poj1631(模板)
    hdoj Max Sum Plus Plus(DP)
    A* 算法详解
    hdoj1043 Eight(逆向BFS+打表+康拓展开)
    hdoj2612 Find a way (bfs)
    luoguP3366 [模板] 最小生成树
    luoguP1196(带权并查集)
  • 原文地址:https://www.cnblogs.com/xinjie/p/1530514.html
Copyright © 2011-2022 走看看