This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

getting error as error C141: syntax error near 'void', expected '__asm' at linevoid lcdcmd(unsigned char val)

#include<reg51.h>
sbit ir1=P1^0; //entry
sbit ir2=P1^1; //exit
sbit rs=P2^0;
sbit rw=P2^1;
sbit en=P2^2;
void lcdcmd(unsigned char);
void lcddat(unsigned char);
void lcddis(unsigned char *s,unsigned char r );
void lcdconv(unsigned char);
void delay();
void main()
{
unsigned char x,y;
lcdcmd(0x38);
delay();
lcdcmd(0x01);
delay();
lcdcmd(0x10);
delay();
lcdcmd(0x0c);
delay();
lcddis("WELCOME",7);
lcdcmd(0xc0);
delay();
lcddis("VISITOR COUNTER",15);
delay();
lcdcmd(0x01);
delay();
while(1)
{
if(ir1==0)
{
lcdcmd(0x80);
delay();
lcddis("ENTRY:",6);
lcdcmd(0x87);
delay();
x=x+1;
lcdconv(x);
}
if(ir2==0)
{
lcdcmd(0xc0);
lcddis("EXIT:",5);
lcdcmd(0xc6);
delay();
y=y+1;
lcdconv(y);
delay();
}
}
void lcdcmd(unsigned char val)
{
P3=val;
rs=0;
rw=0;
en=1;
delay();
en=0;
}
void lcddat(unsigned char dat)
{
P3=dat;
rs=1;
rw=0;
en=1;
delay();
en=0;
}
void lcddis(unsigned char *s,unsigned char r)
{
unsigned char w;
for(w=0;w<r;w++)
{
lcddat(s[w]);
delay();
}
}
void lcdconv(unsigned char num)
{
unsigned char p,n;
p=num/10;
n=num%10;
p=p+0x30;
n=n+0x30;
lcddat(p);
lcddat(n);
}
void delay()
{
unsigned char k,l;
for(k=0;k<1000;k++);
for(l=0;l<100;l++);
}

Parents
  • You're missing the closing brace to the while loop. The code you need is }, properly placed.

    Some indentation would help you find these errors more easily. Also, the MDK editor highlights parentheses so that it's easier to see matches. I'd hope the 8051 tools did, too. If they don't, editors like Visual Studio Code will.

Reply
  • You're missing the closing brace to the while loop. The code you need is }, properly placed.

    Some indentation would help you find these errors more easily. Also, the MDK editor highlights parentheses so that it's easier to see matches. I'd hope the 8051 tools did, too. If they don't, editors like Visual Studio Code will.

Children