首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

用nios环境驱动1602出现的问题

用nios环境驱动1602出现的问题

我用的DE2开发板,SOPC中加了LCD的IP,,引脚肯定没问题了.

nios程序是

//lcd.c
#include <unistd.h>
#include <string.h>
#include <io.h>
#include "system.h"
#include "altera_avalon_pio_regs.h"
#include "LCD.h"
int main (void) __attribute__ ((weak, alias ("alt_main")));

//-------------------------------------------------------------------------
int i;
void LCD_Init()
{
lcd_write_cmd(LCD_16207_0_BASE,0x38);
usleep(2000);
lcd_write_cmd(LCD_16207_0_BASE,0x0C);
usleep(2000);
lcd_write_cmd(LCD_16207_0_BASE,0x01);
usleep(2000);
lcd_write_cmd(LCD_16207_0_BASE,0x06);
usleep(2000);
lcd_write_cmd(LCD_16207_0_BASE,0x80);
usleep(2000);
}
//-------------------------------------------------------------------------
void LCD_Show_Text(char* Text)
{

int i;
for(i=0;i<strlen(Text);i++)
{

lcd_write_data(LCD_16207_0_BASE,Text);
usleep(2000);
}
}
//-------------------------------------------------------------------------
void LCD_Line2()
{
lcd_write_cmd(LCD_16207_0_BASE,0xC0);
usleep(2000);
}
//-------------------------------------------------------------------------
void LCD_Test()
{
char Text1[16] = "1234567 90123456";
char Text2[16] = "1234567890123456";
LCD_Init();
LCD_Show_Text(Text1);
LCD_Line2();
LCD_Show_Text(Text2);
}
int alt_main(void)
{
LCD_Test();
return 0;
}

//lcd.h
#ifndef __LCD_H__
#define __LCD_H__
#include "system.h"
#include "altera_avalon_pio_regs.h"
// LCD Module 16*2
#define lcd_write_cmd(base, data) IOWR(base, 0, data)
#define lcd_read_cmd(base) IORD(base, 1)
#define lcd_write_data(base, data) IOWR(base, 2, data)
#define lcd_read_data(base) IORD(base, 3)
//-------------------------------------------------------------------------


#endif

结果是液晶上有显示,位数也对,但是乱码,第一行一个样,第二行一个样.

其中上面红色的那一行有警告:

Multiple markers at this line
-warning: passing arg 2 of `__builtin_stwio' makes integer from pointer
without a cast
-Line breakpoint: hello_world.c [line: 27]

前辈们指教下

谢谢了!

[此贴子已经被作者于2009-6-5 19:12:01编辑过]

返回列表