导航: 老古网老古论坛XMOS公共讨论区XMOS开源项目区单片机程序设计嵌入式系统广告区域
→大家来看看这个lcd液晶显示程序[stdzm]

 *第15939篇: 大家来看看这个lcd液晶显示程序

  
楼 主:stdzm 2003年9月1日17:29
 大家来看看这个lcd液晶显示程序
大家看看这个lcd 液晶显示的程序
一下是我的lcd 液晶显示的程序,总是有两个错误,望大家给检查一下,程序比较长望大家耐心看,谢谢   其中的错误是:lcd.c(11):error c129:missing';' before'code'
                                          lcd.c(191):error c300: unterminated comment 
  #include   <reg51.h>  
 #include   <absacc.h>  
 #include   <intrins.h>  
 /******LCD****************/
 #define LCD_Data_port p1
 #define LINE1_ADDR 0x00
 #define LINE2_ADDR 0x40
 #define LINE3_ADDR 0x10
 #define LINE4_ADDR 0x50
 /*LCD display table: table_1[]:0~9*/
 uchar code Table_1[10]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39};
 uchar code table_2[10]={0x50,0x4c,0x45,0x53,0x45,0x20,0x57,0x41,0x54,0x45};
 static void LCD_goxy(uchar x, uchar y);//LCD
 static void LCD_string(uchar *s);//write a string to LCD
 static void LCD_clr(void);//clear display
 static void LCD_CMD_Write(uchar pass_value);//write command 
 static void LCD_DAT_Write(uchar pass_value);//Write data
 static void LCD_putbyte(uchar c);//Write a char to LCD
 static void LCD_RAM_Read(void);
 static void LCD_DAT_Read(void);
 void LCD_init(void);//initialize LCD
 

 sbit LCD_RS=p3^0;
 sbit LCD_RW=P3^1;
 sbit LCD_E=p3^5;
/*The main function*/
 void main(void)
{
 int k;
 uchar n;
 LCD_init();
 LCD_clr();
 for(n=0;n  <10;n++)
{
 LCD_DAT_Write(table_2[k++]);
}
 
 

}
/***************************************************
             LCD Function
****************************************************/
/*Locate the coordinate*/
 static void LCD_goxy(uchar x, uchar y)
{
    uchar tmp;
    tmp=x&0xf;
    switch(y)
   {
      case 1:
      tmp|=LINE1_ADDR;
      case 2:
      tmp|=LINE2_ADDR;
      case 3:
      tmp|=LINE3_ADDR;
      case 4:
      tmp|=LINE4_ADDR;
      break;
     }
     LCD_CMD_Write(tmp)
}
/*Write a string to LCD*/
static void LCD_string(uchar *s)
{
 uchar i;
 for(i=0;s[i]!='\0';i++)
    {
 LCD_DAT_Write(s[i]);
    }
/*Clear the display of LCD*/
static void LCD_clr(void)
{
 LCD_busy();
 LCD_CMD_Write(0x01);
 LCD_goxy(1,1);
}
/*Write instruction to LCD*/
void LCD_CMD_Write(unsigned char pass_value)
{
 LCD_busy();
 LCD_RW=0;
 LCD_E=1;
 LCD_E=0;
 LCD_Data_port=pass_value;
 LCD_E=1;
 LCD_E=0;
 }
/*LCD_init:Initialize the LCD*/
void LCD_init(void)
{
 uchar pass;
 uchar i;
 i=3;
 do{
    pass=0x38;
    LCD_RS=0;
    LCD_RW=0;
    _nop_();
    LCD_Data_Port=pass;
    pass=0xff;
    while(pass--);//Delay
    LCD_E=1;
    LCD_E=0;
    }while(i--);
    pass=0x01;
    LCD_CMD_Write(pass);//Clear display and set display data address to 0
    pass=0x06;
    LCD_CMD_Write(pass);//Display data RAM pointer incremented after write
    pass=0x0c;
    LCD_CMD_Write(pass);//Open LCD ,close the cursor and flash 
//***Write a char to LCD***//
void LCD_putbyte(uchar c)

 LCD_DAT_Write(c);
}
/*/
void LCD_DAT_Write(uchar pass_value)
{
 LCD_busy();
 LCD_RS=1;
 LCD_RW=0;
 LCD_Data_Port=pass_value;
 LCD_E=1;
 LCD_E=0;
}
/*Read the value of ACC*/
static uchar LCD_RAM_Read(void)
{
 uchar pass;
 LCD_Data_Port=0xff;
 LCD_RS=0;
 LCD_RW=1;
 LCD_E=1;
 pass=LCD_Data_Port;
 pass=pass&0x7f;
 LCD_E=0;
 return(pass);
}
/*Read data from LCD*/
static uchar LCD_Read(void)
{
 uchar val;
 LCD_busy();
 LCD_RS=1;
 LCD_RW=1;
 LCD_Data_Port=0xff;
 LCD_E=1;
 val=LCD_Data_Port;
 return(val);
 LCD_E=0;
}
void LCD_busy(void)
{
 uchar pass;
 LCD_RS=0;
 LCD_RW=1;
 LCD_Data_Port=0xff;
 do{
    pass=LCD_Data_Port;
   }while(pass&0x80);
   LCD_E=0;
}
/*****************************************
   
 

  
2楼:huzimax 2003年9月1日18:18
 LCD_CMD_Write(tmp)没有;
  
3楼:guest 2003年9月1日18:53
 该程序有何高明?

该程序有何高明?
  
4楼:stdzm 2003年9月2日10:55
 没什么高明只是编译不正确,
  
5楼:tkgg 2003年9月2日23:38
 老兄能帮我一个忙吗?
你好!
    我很喜欢单片机,但至今仍是一只菜鸟,大虾能否帮我一个忙,我对8051如何控制HT1621(或之类的片子)显示LCD一直弄不明白,希望能指点一二。这里先谢谢了!
  
6楼:chang4152 2003年9月4日21:18
 HT1621是什么芯片?
HT1621是什么芯片?
  
7楼:wanggoals 2003年9月6日03:34
 台湾HOLTEK 公司的HT1621 RAM 映射的 32x4 LCD 驱动器
以下是引用chang4152在2003-9-4 21:18:32的发言:
HT1621是什么芯片?


  
8楼:yharbour 2003年9月6日10:01
 你的 uchar 前面没有定义;
改为

你的 uchar 前面没有定义;
改为: unsigned char 或者在前面加:

typdef  uchar unsigned char;

最后注释的格式错误,应为:

/* 注释 */
// 注释


>>>>>>对该主题发表你的看法

本主题贴数8,分页: [第1页]


[上一篇主题]:请问AT89C2051比较器怎么使用

[下一篇主题]:请教各位,我自制个网卡,实现单片机连上INTERNET!!!!