Electronics > Microcontrollers

Compilation Error 8051

(1/1)

Muhammad Nasar:
I have written a C programe to interface AT89S52 with LCD, but when i compile this programe in Microvision Keil 4, it gives this error:
Error:*******************************************
MAIN.c(9): warning C206: 'lcdcmd': missing function-prototype
MAIN.c(9): error C267: 'lcdcmd': requires ANSI-style prototype
*************************************************
The programe is as follows:
****************************************************************************
#include <reg52.h>
sfr ldata= 0x90;
sbit rs = P2^0;
sbit rw = P2^1;
sbit en = P2^2;
sbit busy = P1^7;
void main()
{
 lcdcmd(0x38);
 lcdcmd(0x0E);
 lcdcmd(0x01);
 lcdcmd(0x06);
 lcdcmd(0x86);
 lcddata('M');
 lcddata('D');
 lcddata('E');
}

void lcdcmd(unsigned char value)
{
 lcdready();
 ldata= value;
 rs=0;
 rw=0;
 en=1;
 MSDelay(1);
 en=0;
 return;
}

void lcddata(unsigned char value)
{
 lcdready();
 ldata= value;
 rs=1;
 rw=0;
 en=1;
 MSDelay(1);
 en=0;
 return;
}

void lcdready()
{
 busy=1;
 rs=0;
 rw=1;
 while(busy==1)
  {
  en=0;
  MSDelay(1);
  en=1;
  }
 return;
}
void MSDelay(unsigned int itime)
{
  unsigned int i, j;
  for(i=0;i<itime;i++)
   for(j=0;j<1275;j++);
}
**************************************************************************************
A screen shot has also been attached

Bored@Work:
Exactly what the compiler says. You are using a function before the compiler has seen at least a declaration of the function. Either add a forward declaration, or move the function and main in the compilation unit around, so the function definition is before the first usage.

Muhammad Nasar:
Thanks, Problem solved :)

Navigation

[0] Message Index

There was an error while thanking
Thanking...
Go to full version