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

* 41234: 大家来看看这个lcd液晶显示程序

   stdzm 
stdzm发表的帖子 

 大家来看看这个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;
}
/*****************************************
   
 


发表时间:2003年9月1日17:29:47

  
回复该帖

本主题共有 8 帖,分页:>>>>>该主题的所有内容[8]条

 *树形目录 只列出部分跟帖的标题以及简单的摘要信息 该主题的部分跟帖如下:

  41236.[详细]LCD_CMD_Write(tmp)没有;
摘要:......(无内容)
- [huzimax][964次] 2003年9月1日

  41242.[详细]该程序有何高明?
摘要:该程序有何高明? ......(17字)
- [guest][784次] 2003年9月1日

  41284.[详细]没什么高明只是编译不正确,
摘要:......(无内容)
- [stdzm][937次] 2003年9月2日

[上一篇帖子]:请问AT89C2051比较器怎么使用请问AT89C2051比较器怎么使用,我想做一个测温电路,用热敏
[下一篇帖子]:请教各位,我自制个网卡,实现单片机连上INTERNET!!!!请教各位,我自制个网卡,实现单片机连上