Results 1 to 3 of 3

Thread: How to "printf" to my 16207 Optrex lcd controller ?

  1. #1
    Join Date
    Feb 2011
    Location
    St Cloud, MN
    Posts
    123
    Rep Power
    1

    Default How to "printf" to my 16207 Optrex lcd controller ?

    Hi there,

    I've spent lots of time on this, but S.O.L.. cant solve this one.

    I am trying to output a string of texts (sometimes with integer variable) to my LCD controller using printf() (or similar) through NIOS 2, using Eclipse IDE.

    I can verify my connection is good, and my LCD and NIOS 2 works fine too, as i can use the HAL to manually initialize the LCD, delay, and also to output text like the following;

    ///////////////////////////////////////////////////////////////////////////////////////
    void lcd_init(void){
    IOWR_ALTERA_AVALON_LCD_16207_COMMAND(LCD_BASE, 0x38);
    usleep(1000);
    IOWR_ALTERA_AVALON_LCD_16207_COMMAND(LCD_BASE, 0x0C);
    usleep(1000);
    IOWR_ALTERA_AVALON_LCD_16207_COMMAND(LCD_BASE, 0x01);
    usleep(1000);
    IOWR_ALTERA_AVALON_LCD_16207_COMMAND(LCD_BASE, 0x06);
    usleep(1000);
    }

    ///////////////////////////////////////////////////////////////////////////
    void lcd_print(char *pText){
    int i=0;

    while(pText[i]!='\0') // loop until the eof
    {
    switch(pText[i])
    {
    case '\f':IOWR_ALTERA_AVALON_LCD_16207_COMMAND(LCD_BASE , 1);
    usleep(2000);
    break;
    case '\n':IOWR_ALTERA_AVALON_LCD_16207_COMMAND(LCD_BASE , 0xC0);
    usleep(1000);
    break;
    default: IOWR_ALTERA_AVALON_LCD_16207_DATA(LCD_BASE, pText[i] );
    usleep(1000);
    break;
    }

    i++; // get ready for the next character in the string
    } // end of while
    return;
    }
    /////////////////////////////////////////////////////////////////////////////////


    I wrote these functions, it works well, but it does not take any variable like the following;
    lcd_print("the number is: %d", A) .
    my function can only output pure ASCII character.

    I found some example online that could potentially do this, shown in the following;

    //////////////////////////////////////////////////////////

    FILE* fp;
    fp= fopen("LCD_NAME", "w");

    if (fp == NULL) {
    fprintf(stderr, "open failed\n"); return 0;
    }

    fprintf(fp, "The time now is %d", time);

    //////////////////////////////////////////////////////////////

    I can't make this code work. my question is WHY??
    I don't understand how this code can work, as it does not initialize, and it does not contain any delay. Can anyone correct this?



    Thank you.

    Michael

  2. #2
    Join Date
    Nov 2008
    Location
    Tuam, Ireland
    Posts
    1,161
    Rep Power
    1

    Default Re: How to "printf" to my 16207 Optrex lcd controller ?

    In Nios II software build tools (Eclipse), make a new program from example. I am sure there is LCD routine in Web Server example since it shows IP address in the LCD, but You can check board diagnostics or other examples containing LCD control source.

  3. #3
    Join Date
    Feb 2011
    Location
    St Cloud, MN
    Posts
    123
    Rep Power
    1

    Default Re: How to "printf" to my 16207 Optrex lcd controller ?

    Quote Originally Posted by Socrates View Post
    In Nios II software build tools (Eclipse), make a new program from example. I am sure there is LCD routine in Web Server example since it shows IP address in the LCD, but You can check board diagnostics or other examples containing LCD control source.
    Hi,

    My LCD routine works now. As you said, i used the code from a template file. But i dun quite understand the template file.
    Do you know how this line works??

    FILE* fp;
    fp= fopen(LCD_DISPLAY_NAME, "w");

    am i writing to the internal physical memory of the LCD module?? otherwise where is this file located at?


    regards,
    Michael
    Last edited by lewy0701; September 8th, 2011 at 08:44 AM.

Similar Threads

  1. Error: Port "i1" does not exist in primitive "nand2" of instance "g2"
    By alizadeharand in forum Quartus II and EDA Tools Discussion
    Replies: 1
    Last Post: July 24th, 2011, 10:23 PM
  2. cannot printf "hello world"
    By hebeiwuyou in forum Development Kit Related
    Replies: 4
    Last Post: December 28th, 2010, 02:31 AM
  3. Port "data0" does not exist in primitive "and2" of instance "U1"
    By robocon in forum Quartus II and EDA Tools Discussion
    Replies: 12
    Last Post: December 5th, 2010, 03:52 AM
  4. printf("Hello World \n\r")
    By larsen in forum General Software Forum
    Replies: 5
    Last Post: February 13th, 2007, 07:03 AM
  5. printf("") in an interrupt handler
    By larsen in forum General Software Forum
    Replies: 2
    Last Post: October 14th, 2004, 05:56 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •