--- Quote Start ---
originally posted by jwlam@Aug 28 2006, 04:04 AM
i got this code from here (http://forum.niosforum.com/forum/index.php?showtopic=229). this code initialize the lcd module.
#include <unistd.h># include <stdlib.h># include <stdio.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(10);
pio_lcd_io_command=lcd_cmd_function_set | lcd_cmd_8bit;
delay(10);
pio_lcd_io_command=lcd_cmd_function_set | lcd_cmd_8bit | lcd_cmd_two_line;
delay(10);
pio_lcd_io_command=lcd_cmd_onoff;
delay(10);
pio_lcd_io_command=lcd_cmd_clear;
delay(10);
pio_lcd_io_command=lcd_cmd_modes | lcd_cmd_mode_inc;
delay(10);
pio_lcd_io_command=lcd_cmd_onoff | lcd_cmd_enable_disp;
delay(1000);
return 0;
}
my question is: how to i print characters to the screen? i suppose i shud look for the address of the pins rs, r/w, and e. but i've yet to locate them.
at the mean time, i'm going thru pio_lcd16207.c and pio_lcd16207.h. i think i understand wat these codes r trying to do but i've yet to come out with a prog tat works.
pls advice. thx in advance.
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=17891)</div> --- Quote End ---
this is regester map address,pls see linux driver book,could anyone post the lcd driver?thanks