LCD Display program in C

Status
Not open for further replies.

vead

Full Member level 5
Joined
Nov 27, 2011
Messages
285
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
india
Activity points
3,815
Hello
I am using AT89c51 microcntroller and Keil compiler. when I build code I am getting error

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include<reg51.h>
#define LCDPORT P1
#define RS P2_0
#define RW P2_1
#define E P2_3
bit status=0
#define lcd_delay 60
void delay(unsigned int j)
{
unsigned int i,k;
for(i=0;i<j;i++);
 
for(k=0;k<100;k++);
 
}
void _lcd_init_write(unsigned char a)
{
RS = 0;
RW = 0;
LCDPORT=a;
E=1;
delay(lcd_delay);
E=0;
}
void lcd_com(unsigned char a){
unsigned char temp;
if(status){
status=0;
goto a;
}
RS=0;
a:
RW=0;
temp=a;
temp&=0xF0;
LCDPORT&=0x0F;
LCDPORT|=temp;
E=1;
delay(lcd_delay);
E=0;
temp=a<<4;
temp&=0xF0;
LCDPORT&=0x0F;
LCDPORT|=temp;
E=1;
delay(lcd_delay);
E=0;
}
void lcd_data(unsigned char a){
status=1;
RS=1;
lcd_com(a);
}
void lcd_init(void){
delay(lcd_delay);
_lcd_init_write(0x30);
delay(lcd_delay);
_lcd_init_write(0x30);
delay(lcd_delay);
_lcd_init_write(0x30);
delay(lcd_delay);
_lcd_init_write(0x20);
delay(lcd_delay);
lcd_com(0x28);
delay(lcd_delay);
lcd_com(4);
delay(lcd_delay);
lcd_com(0x85);
delay(lcd_delay);
lcd_com(6);
delay(lcd_delay);
lcd_com(1);
delay(lcd_delay);
}
void lcd_puts(char *aaa)
{
unsigned int i=0;
for(;aaa[i]!=0;i++)lcd_data(aaa[i]);
}



Error Message

why I am getting this error. how to remove error ?
 

This type of errors occurs when you miss syntax (not putting a semicolon, putting it in the wrong place etc). So when you get this error, look for it just BEFORE the error statement, in your case before 'void'.
At first I thought about reg51.h file, but then I saw the line among the defines:

Code C - [expand]
1
bit status=0


As it's a variable definition, regular c-code, it must ends with a semicolon.

Although C allows placing #define anywhere in the code, it's a good practise to place them in the beginning, and surely not mix them with c-code. It is more readable.
And make lcd_delay with capitalized letters, again, it's more readable.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…