Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
21 years ago

What's wrong with my programm?

I have write a programme to initialize the lcd16207,but it couldn&#39;t work correctly. The code is:# include <unistd.h># include <stdlib.h># include <stdio.h>

//#include "lcd_16207.h"

/* Commands which can be written to the COMMAND register */

enum /* Write to character RAM */

{

LCD_CMD_WRITE_DATA = 0x80

/* Bits 6:0 hold character RAM address */

};

enum /* Write to character generator RAM */

{

LCD_CMD_WRITE_CGR = 0x40

/* Bits 5:0 hold character generator RAM address */

};

enum /* Function Set command */

{

LCD_CMD_FUNCTION_SET = 0x20,

LCD_CMD_8BIT = 0x10,

LCD_CMD_TWO_LINE = 0x08,

LCD_CMD_BIGFONT = 0x04

};

enum /* Shift command */

{

LCD_CMD_SHIFT = 0x10,

LCD_CMD_SHIFT_DISPLAY = 0x08,

LCD_CMD_SHIFT_RIGHT = 0x04

};

enum /* On/Off command */

{

LCD_CMD_ONOFF = 0x08,

LCD_CMD_ENABLE_DISP = 0x04,

LCD_CMD_ENABLE_CURSOR = 0x02,

LCD_CMD_ENABLE_BLINK = 0x01

};

enum /* Entry Mode command */

{

LCD_CMD_MODES = 0x04,

LCD_CMD_MODE_INC = 0x02,

LCD_CMD_MODE_SHIFT = 0x01

};

enum /* Home command */

{

LCD_CMD_HOME = 0x02

};

enum /* Clear command */

{

LCD_CMD_CLEAR = 0x01

};# define na_lcd_pio_command ((volatile int *) 0x80920850)# define na_lcd_pio_status ((volatile int *) 0x80920851)# define na_lcd_pio_wr_data ((volatile int *) 0x80920852)# define na_lcd_pio_rd_data ((volatile int *) 0x80920853)

# define PIO_LCD_IO_COMMAND (*na_lcd_pio_command)# define PIO_LCD_IO_STATUS (*na_lcd_pio_status)# define PIO_LCD_IO_WR_DATA (*na_lcd_pio_wr_data)# define PIO_LCD_IO_RD_DATA (*na_lcd_pio_rd_data)

void delay(int para)//delay for 0.2*para ms

{

int i=0,j=0;

for(i=0;i<para;i++)

for(j=0;j<10000;j++)

}

int main()

{

delay(75);

PIO_LCD_IO_COMMAND=LCD_CMD_FUNCTION_SET | LCD_CMD_8BIT;

delay(21);

PIO_LCD_IO_COMMAND=LCD_CMD_FUNCTION_SET | LCD_CMD_8BIT;

delay(1);

PIO_LCD_IO_COMMAND=LCD_CMD_FUNCTION_SET | LCD_CMD_8BIT;

PIO_LCD_IO_COMMAND=LCD_CMD_FUNCTION_SET | LCD_CMD_8BIT | LCD_CMD_TWO_LINE;

PIO_LCD_IO_COMMAND=LCD_CMD_ONOFF;

PIO_LCD_IO_COMMAND=LCD_CMD_CLEAR;

PIO_LCD_IO_COMMAND=LCD_CMD_MODES | LCD_CMD_MODE_INC;

PIO_LCD_IO_COMMAND=LCD_CMD_ONOFF | LCD_CMD_ENABLE_DISP;

delay(1000);

return 0;

}

My operation system is uClinux,and the board is cyclone,what&#39;s wrong with me? help!

15 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks for all the replies,you are very hot heart!

    And now my problem has been resolved.

    My cpu core is nios2,and the os is uClinux. I have write a function that can work at any platform to control the lcd16207.

    Last i should say that you could not use the HAL under uClinux. So you must write data to the port directly.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks for all the replies,you are very hot hearted!

    And now my problem has been resolved.

    My cpu core is nios2,and the os is uClinux. I have write a function that can work at any platform to control the lcd16207.

    Last i should say that you could not use the HAL under uClinux. So you must write data to the port directly.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Didn&#39;t know that. Isn&#39;t the HAL stuff more useful for software developers who write code targetting a system with an OS though? I understand the HAL is meant to make things easier for software developers, but if it doesn&#39;t work with the OS then the people who are already used to writing directly (low level programmers) are the ones making the switch (seems kinda backwards to me).

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    The problem is in the implementation of the installation.

    We (Altera) is working on a doc to give to third parties that will tell them the do&#39;s and don&#39;ts of Installing Eclipse plugins.

    Only workaround is to install the Nios II product again (I think).
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    originally posted by blackslave@Aug 12 2004, 08:51 PM

    thanks for all the replies,you are very hot hearted!

    and now my problem has been resolved.

    my cpu core is nios2,and the os is uclinux. i have write a function that can work at any platform to control the lcd16207.

    last i should say that you could not use the hal under uclinux. so you must write data to the port directly.

    <div align='right'><{post_snapback}> (index.php?act=findpost&pid=920)

    --- quote end ---

    --- Quote End ---

    Blackslave,

    Do you mind sharing the code ? I am trying to do this as well ...

    Pls help.