code problem - using 8051 microcontroller (AT89S52)

Status
Not open for further replies.

Thread Starter

Muhamad

Joined Mar 31, 2015
14
I have problem when compiler this code, can anyone help me?

I use keil software.. This is the problem that i got



Build target 'Target 1'
compiling My.c...
My.c(2): warning C318: can't open file 'lcddisplay.h'
My.c(16): warning C206: 'lcd_init': missing function-prototype
My.c(17): warning C206: 'lcdcmd': missing function-prototype
My.c(17): error C267: 'lcdcmd': requires ANSI-style prototype
Target not created.
This is my code..



#include<reg51.h>
#include"lcddisplay.h"
#include<intrins.h>
sbit rd = P2^0;
sbit wr = P2^1;
sbit intr = P2^2;
sbit finger = P2^5;
sbit buz = P2^3;
#define adcdata P3
void convert(unsigned char );
unsigned char a,pp=0,count=0,i;
void main()
{
buz=0;
finger=1;
lcd_init();
lcdcmd(0x85);
msgdisplay("WELCOME");
lcdcmd(0x01);
msgdisplay("temp hbeat");
rd=1;
intr=1;
adcdata=0xff;
while(1)
{
lcdcmd(0xc2);
//delay(500);
wr=0;
_nop_();
_nop_();
_nop_();
_nop_();
wr=1;
delay(50);
rd=0;
delay(10);
a=adcdata;
convert(a);
delay(500);
for(i=0;i<100;i++)
{
count+=1;
if(finger==0)
{
delay(1000);
if(!finger)
{
buz=1;
delay(500);
pp=1;
buz=0;
break;
}
else
pp=0;
}
}
delay(500);
lcdcmd(0xca);
if(pp)
{
convert(count);
}
else
convert(0);
pp=0;
}
}
void convert(unsigned char temp_value)
{
unsigned char value,d1,d2,d3;
temp_value = temp_value;
value=temp_value/10;
d3=temp_value%10;
d1=value/10;
d2=value%10;
d1=d1+0x30;
lcddata(d1);
delay(10);
d2=d2+0x30;
lcddata(d2);
delay(4);
// msgdisplay(".");
d3=d3+0x30;
lcddata(d3);
delay(10);
}




Can anyone help me to fix the code?
 

JohnInTX

Joined Jun 26, 2012
4,787
My.c(2): warning C318: can't open file 'lcddisplay.h'
The compiler can't find the include file. The other errors are a result of this.
#include"lcddisplay.h"
Putting the file name in quotes implies that the file is in the same source location as the .c file. Putting it in brackets i.e. #include <file.h> will tell the compiler to look in standard places (a directory called INC maybe. You can also specify the search paths for includes (and other files) in the project configuration.

" " and <> searching can vary with the compiler implementation. Check the manual for your compiler.

Good luck.
 

Thread Starter

Muhamad

Joined Mar 31, 2015
14
The compiler can't find the include file. The other errors are a result of this.
Putting the file name in quotes implies that the file is in the same source location as the .c file. Putting it in brackets i.e. #include <file.h> will tell the compiler to look in standard places (a directory called INC maybe. You can also specify the search paths for includes (and other files) in the project configuration.

" " and <> searching can vary with the compiler implementation. Check the manual for your compiler.

Good luck.
When i use " " or < > still have a error
 

JohnInTX

Joined Jun 26, 2012
4,787
As Mr. Chips says, be sure the file actually exists - and that the LCD library it describes likewise exists.
When you find both, add the path to the files to the project configuration so that the compiler can find the .h file and so the linker can find the library.
 

Thread Starter

Muhamad

Joined Mar 31, 2015
14
As Mr. Chips says, be sure the file actually exists - and that the LCD library it describes likewise exists.
When you find both, add the path to the files to the project configuration so that the compiler can find the .h file and so the linker can find the library.
if the file no exist, what should i do?
 

JohnInTX

Joined Jun 26, 2012
4,787
You are trying to use code that requires LCD support routines that are in a separate library. You have a couple of options 1) go back to where you got the code and see if you can get the library it needs to compile 2)write your own LCD routines 3)see if the Kiel compiler has any libraries that don't get installed by default and install them. If the code was originally written for another compiler - especially MikroC - the libraries were probably installed as part of the development package. Now they are missing. You could search for *.h (all header files) and see if there is something that looks like it - maybe its misspelled or there's a different version.

As it stands, the code won't compile/link because it is incomplete.

If you want to code your own LCD routines there are many, many threads here on AAC that discuss that topic in great detail. Search away!

Good luck
 
Last edited:

Thread Starter

Muhamad

Joined Mar 31, 2015
14
You are trying to use code that requires LCD support routines that are in a separate library. You have a couple of options 1) go back to where you got the code and see if you can get the library it needs to compile 2)write your own LCD routines 3)see if the Kiel compiler has any libraries that don't get installed by default and install them. If the code was originally written for another compiler - especially MikroC - the libraries were probably installed as part of the development package. Now they are missing. You could search for *.h (all header files) and see if there is something that looks like it - maybe its misspelled or there's a different version.

As it stands, the code won't compile/link because it is incomplete.

If you want to code your own LCD routines there are many, many threads here on AAC that discuss that topic in great detail. Search away!

Good luck
Can you teach me how to add the .h header? I still new with the software that i use.
 

JohnInTX

Joined Jun 26, 2012
4,787
Not really, because there is nothing to teach. You don't have the file(s) you need to complete the code so you are left with the options I noted.

Its like you were cooking a recipe which described how to prepare and cook the meat but referred you to another cookbook for the sauce. You go to the shelf and that cookbook is missing - no sauce - no dinner. Whoever wrote the original code used parts from another 'cookbook' i.e. the LCD library. Without that, you are on your own to find the library, with its .h file that is like a description of what functions is has in it, and put the files where the compiler can find them. Once you have the files, look in Keil's help under Libraries and it will tell you what it wants.

But you gotta have the files - the .h AND the library that goes with it - or write your own. Sorry, that's about all there is to it.
 
Status
Not open for further replies.
Top