大家来看看这个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