Author Topic: Compilation Error 8051  (Read 4377 times)

0 Members and 1 Guest are viewing this topic.

Offline Muhammad NasarTopic starter

  • Contributor
  • Posts: 22
Compilation Error 8051
« on: March 23, 2012, 03:05:51 pm »
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
 

Offline Bored@Work

  • Super Contributor
  • ***
  • Posts: 3932
  • Country: 00
Re: Compilation Error 8051
« Reply #1 on: March 23, 2012, 03:41:14 pm »
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.
« Last Edit: March 23, 2012, 03:44:58 pm by BoredAtWork »
I delete PMs unread. If you have something to say, say it in public.
For all else: Profile->[Modify Profile]Buddies/Ignore List->Edit Ignore List
 

Offline Muhammad NasarTopic starter

  • Contributor
  • Posts: 22
Re: Compilation Error 8051
« Reply #2 on: March 23, 2012, 07:08:20 pm »
Thanks, Problem solved :)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf