Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

[General] Code Error in keil....

Status
Not open for further replies.

gauravkothari23

Advanced Member level 1
Joined
Mar 21, 2015
Messages
491
Helped
3
Reputation
6
Reaction score
3
Trophy points
18
Activity points
4,655
Hi friends....
plz help me
as i am new for programming...
i wrote the code in c but am getting an error in keil as

Project1.c(19): warning C206: 'Lcd8_Cmd': missing function-prototype
Project1.c(19): error C267: 'Lcd8_Cmd': requires ANSI-style prototype...
my code is......

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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
#include<reg51.h>
#include<delay.h>
#include<lcd.h>
#include<keypad.h>
 
void lcd_cmd(unsigned char );
void lcddata(unsigned char );
void lcdready();
void MSDelay(unsigned int );
sbit LEDg=P2^4;
sbit LEDr=P2^3;
 
//// FUNCTIONS FOR LOCK image on LCD////
void lock()
{
Lcd8_Cmd(72);
Lcd8_Write_Char(0);
Lcd8_Write_Char(14);
Lcd8_Write_Char(10);
Lcd8_Write_Char(10);
Lcd8_Write_Char(31);
Lcd8_Write_Char(27);
Lcd8_Write_Char(31);
Lcd8_Cmd(0xcf);
Lcd8_Write_Char(1);
 
}
void open()
{
Lcd8_Cmd(72);
Lcd8_Write_Char(14);
Lcd8_Write_Char(10);
Lcd8_Write_Char(2);
Lcd8_Write_Char(2);
Lcd8_Write_Char(31);
Lcd8_Write_Char(27);
Lcd8_Write_Char(31);
Lcd8_Cmd(0xcf);
Lcd8_Write_Char(1);
}
 
//// FUNCTION INPUTTING VALES FROM USERS AND STORING THEM TO AN ARRAY////
void input(char arr[])
{ unsigned char i=0,k=0,N[16];
Lcd8_Cmd(0xc0);
while(k!='#')
{
k=Read_Keypad();
if(k && k!='#')
{
N[i++]=k;
Lcd8_Write_Char('*');
}
}
strcpy(arr,N);
arr[i]='\0';
}
 
void main()
{
unsigned char P[16]={"000"}; ///default password
 
while(1)
{ unsigned char p[16],s[16],j;
 
LEDg=0;LEDr=1;
Lcd8_Init();
lock();
Lcd8_Cmd(0x80);
Lcd8_Write_String("ENTER PASSWORD");
input(p);
 
if(strcmp(p,P)==0)
{
Lcd8_Init();
open();
Lcd8_Cmd(0x80);
Lcd8_Write_String("ACCESS GRANTED");
LEDr=0;LEDg=1;
while(Read_Keypad()!='#')
{}
}
else if(strcmp(p,"*")==0)
{
Lcd8_Init();
lock();
Lcd8_Cmd(0x80);
Lcd8_Write_String("CURRENT PASSWORD");
input(p);
 
if(strcmp(p,P)==0)
{
Lcd8_Init();
lock();
Lcd8_Cmd(0x80);
Lcd8_Write_String("NEW PASSWORD");
input(s);
 
Lcd8_Init();
lock();
Lcd8_Cmd(0x80);
Lcd8_Write_String("CONFIRM PASSWORD");
input(p);
 
if(strcmp(p,s)==0)
{ j=strlen(s);
strcpy(P,s);
P[++j]='\0';
Lcd8_Init();
lock();
Lcd8_Cmd(0x80);
Lcd8_Write_String("CHANGE");
Lcd8_Cmd(0xc0);
Lcd8_Write_String("SUCCESSFULL");
while(Read_Keypad()!='#')
{}
}
else
{
Lcd8_Init();
lock();
Lcd8_Cmd(0x80);
Lcd8_Write_String("CHANGE");
Lcd8_Cmd(0xc0);
Lcd8_Write_String("UNSUCCESSFULL");
while(Read_Keypad()!='#')
{}
}
}
else
{
Lcd8_Init();
lock();
Lcd8_Cmd(0x80);
Lcd8_Write_String("WRONG PASSWORD");
delay_msec(2000);
}
}
else
{
Lcd8_Init();
lock();
Lcd8_Cmd(0x80);
Lcd8_Write_String("ACCESS DENIED");
LEDr=0;delay_msec(250); LEDr=1;delay_msec(250);
LEDr=0;delay_msec(250);
LEDr=1;delay_msec(250);
LEDr=0;delay_msec(250);
LEDr=1;delay_msec(250);
}
}
}
 
 
 
----------------------------------------------------------------------------------
 
CODE (delay.h)
 
----------------------------------------------------------------------------------
void delay_msec(int time)
{int i=0;
while(i<time)
{TMOD=0x10;
TH1=0xfc;
TL1=0x65;
TR1=1;
while(TF1==0);
TR1=0;
TF1=0;
i++;
}
}
 
 
--------------------------------------------------------------------------------------
CODE (lcd.h)
--------------------------------------------------------------------------------------
#include<string.h>
//LCD Module Connections
sbit RS=P2^0;
sbit RW=P2^1;
sbit E=P2^2;
//End LCD Module Connections
 
char *string;
//LCD 8 Bit Interfacing Functions
 
void Lcd8_Cmd(unsigned char value)
{
P3=value;
RS=0;
RW=0;
E=1;
delay_msec(1);
E=0;
}
 
void Lcd8_Init()
{
Lcd8_Cmd(0x38); //function set
Lcd8_Cmd(0x0C); //display on,cursor off,blink off
Lcd8_Cmd(0x01); //clear display
Lcd8_Cmd(0x06); //entry mode, set increment
}
 
void Lcd8_Write_Char(unsigned char value)
{
 
P3=value;
RS=1;
RW=0;
E=1;
delay_msec(1);
E=0;
}
 
void Lcd8_Write_String(char *a)
{
int i;
string=a;
for(i=0;a[i]!='\0';i++)
Lcd8_Write_Char(a[i]);
}
 
void Lcd8_Shift_Right()
{ int j;
for(j=0;j<strlen(string);j++)
{Lcd8_Cmd(0x1C);delay_msec(100);}
}
 
void Lcd8_Shift_Left()
{ int k;
for(k=0;k<strlen(string);k++)
{Lcd8_Cmd(0x18);delay_msec(100);}
}
 
 
 
------------------------------------------------------------------------------
CODE (keypad.h)
 
------------------------------------------------------------------------------
sbit R1 = P1^0;
sbit R2 = P1^1;
sbit R3 = P1^2;
sbit R4 = P1^3;
 
sbit C1 = P1^4;
sbit C2 = P1^5;
sbit C3 = P1^6;
sbit C4 = P1^7;
 
//End Keypad Connections
 
char Read_Keypad()
{
C1=C2=C3=C4=1;
 
R1=0;
R2=1;
R3=1;
R4=1;
if(C1==0){while(C1==0);return '1';}
if(C2==0){while(C2==0);return '2';}
if(C3==0){while(C3==0);return '3';}
if(C4==0){while(C4==0);return 'A';}
R1=1;
R2=0;
R3=1;
R4=1;
if(C1==0){while(C1==0);return '4';}
if(C2==0){while(C2==0);return '5';}
if(C3==0){while(C3==0);return '6';}
if(C4==0){while(C4==0);return 'B';}
R1=1;
R2=1;
R3=0;
R4=1;
if(C1==0){while(C1==0);return '7';}
if(C2==0){while(C2==0);return '8';}
if(C3==0){while(C3==0);return '9';}
if(C4==0){while(C4==0);return 'C';}
R1=1;
R2=1;
R3=1;
R4=0;
if(C1==0){while(C1==0);return '*';}
if(C2==0){while(C2==0);return '0';}
if(C3==0){while(C3==0);return '#';}
if(C4==0){while(C4==0);return 'D';}
return 0;
}

 
Last edited by a moderator:

Gorgon

Full Member level 6
Joined
Nov 10, 2005
Messages
345
Helped
75
Reputation
150
Reaction score
67
Trophy points
1,308
Location
Norway
Activity points
3,637
You need to define the function prototype before you call the function the first time.

Normally this is done in the appropriate header file you include in the start of the xxx.c file. The abc.h file includes normally only definitions and prototypes, and the abc.c file the code part of the functions.
 

gauravkothari23

Advanced Member level 1
Joined
Mar 21, 2015
Messages
491
Helped
3
Reputation
6
Reaction score
3
Trophy points
18
Activity points
4,655
Thanks a lot for reply....
but am sorry am not getting your points....
can u plz... make it bit clearly...
 

andre_teprom

Super Moderator
Staff member
Joined
Nov 7, 2006
Messages
9,181
Helped
1,141
Reputation
2,301
Reaction score
1,116
Trophy points
1,403
Location
Brazil
Activity points
53,327
am not getting your points
As Gorgon mentioned, as a good practice you should put the prototype at a separate file, but for keep testing, in order to eliminate current errors from compilation, could make some fixes:

At line 5, insert the code bellow :

Code:
void Lcd8_Write_Char(unsigned char value);
At line 259, you wrote something that I guess is not allowed in ansi-c:

Code:
C1=C2=C3=C4=1;
 

gauravkothari23

Advanced Member level 1
Joined
Mar 21, 2015
Messages
491
Helped
3
Reputation
6
Reaction score
3
Trophy points
18
Activity points
4,655
Thanks a lot....
I have don the changes.. but again i am getting an error.... saying that...
msdelay.... not in a formal parameter list....
what does it mean....
plzz help me....

- - - Updated - - -

thanks a lot....
but again i am getting an error saying that.....
msdelay... not in a formal parameter list....
what does it mean... and what is the solution....
plzz. help me....
 

andre_teprom

Super Moderator
Staff member
Joined
Nov 7, 2006
Messages
9,181
Helped
1,141
Reputation
2,301
Reaction score
1,116
Trophy points
1,403
Location
Brazil
Activity points
53,327
Follow these steps :
  • Open the file delay.h
  • Look on it for the function delay_msec
  • Insert the prototype for this function at beggining of the code.
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top