what problem with my code using 8051 microcontroller (AT89S52)

Thread Starter

Muhamad

Joined Mar 31, 2015
14
I want to ask. I use keil compiler. When I compiler the code, the software give warning and error. This is the warning and error.. How can I fix the error??

The question is, if i burn this code into pic, is it the pic working well with the code and not counter with problem? Please can anybody help me??

Code:
Build target 'Target 1'
linking...
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    SYMBOL:  _DELAY
    MODULE:  Project.obj (PROJECT)
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    SYMBOL:  _MSGDISPLAY
    MODULE:  Project.obj (PROJECT)
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    SYMBOL:  LCD_INIT
    MODULE:  Project.obj (PROJECT)
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    SYMBOL:  _LCDDATA
    MODULE:  Project.obj (PROJECT)
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    SYMBOL:  _LCDCMD
    MODULE:  Project.obj (PROJECT)
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  LCD_INIT
    MODULE:  Project.obj (PROJECT)
    ADDRESS: 0805H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  _LCDCMD
    MODULE:  Project.obj (PROJECT)
    ADDRESS: 080AH
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  _MSGDISPLAY
    MODULE:  Project.obj (PROJECT)
    ADDRESS: 0813H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  _LCDCMD
    MODULE:  Project.obj (PROJECT)
    ADDRESS: 0818H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  _MSGDISPLAY
    MODULE:  Project.obj (PROJECT)
    ADDRESS: 0821H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  _LCDCMD
    MODULE:  Project.obj (PROJECT)
    ADDRESS: 082DH
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  _DELAY
    MODULE:  Project.obj (PROJECT)
    ADDRESS: 083CH
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  _DELAY
    MODULE:  Project.obj (PROJECT)
    ADDRESS: 0845H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  _DELAY
    MODULE:  Project.obj (PROJECT)
    ADDRESS: 0854H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  _DELAY
    MODULE:  Project.obj (PROJECT)
    ADDRESS: 0863H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  _DELAY
    MODULE:  Project.obj (PROJECT)
    ADDRESS: 086FH
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  _DELAY
    MODULE:  Project.obj (PROJECT)
    ADDRESS: 0889H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  _LCDCMD
    MODULE:  Project.obj (PROJECT)
    ADDRESS: 088EH
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  _LCDDATA
    MODULE:  Project.obj (PROJECT)
    ADDRESS: 094FH
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  _DELAY
    MODULE:  Project.obj (PROJECT)
    ADDRESS: 0956H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  _LCDDATA
    MODULE:  Project.obj (PROJECT)
    ADDRESS: 0960H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  _DELAY
    MODULE:  Project.obj (PROJECT)
    ADDRESS: 0967H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  _LCDDATA
    MODULE:  Project.obj (PROJECT)
    ADDRESS: 0971H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  _DELAY
    MODULE:  Project.obj (PROJECT)
    ADDRESS: 0978H
Program Size: data=15.0 xdata=0 code=407
"Project" - 0 Error(s), 24 Warning(s).
This is my code.

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 );
void lcd_init(void);
void lcdcmd(unsigned char value);
void msgdisplay (unsigned char*);
void delay(int);
void lcddata(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);
}

#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 );
void lcd_init(void);
void lcdcmd(unsigned char value);
void msgdisplay (unsigned char*);
void delay(int);
void lcddata(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);
}
Moderators note : Please use code tags for pieces of code.
 
Last edited by a moderator:

Papabravo

Joined Feb 24, 2006
15,032
The code will not work on a PIC.

When modules are compiled and linked, an unresolved external symbol means that you forgot to include the proper libraries in your project.

This is not a warning, it is a fatal error. If any code was generated it certainly will not run correctly or even at all.
 

Thread Starter

Muhamad

Joined Mar 31, 2015
14
The code will not work on a PIC.

When modules are compiled and linked, an unresolved external symbol means that you forgot to include the proper libraries in your project.

This is not a warning, it is a fatal error. If any code was generated it certainly will not run correctly or even at all.
How can I fix it? I don't what should i do because i still newbie with proggramming.
 

Papabravo

Joined Feb 24, 2006
15,032
You need to find the modules with the functions you need and include them in your project. Where do you think those functions are located? What document did you read that informed you of the existence of those functions. Was it the Keil documentation? Was it some site on the interwebz? Tell us what you're doing so we can help you.
 

MrChips

Joined Oct 2, 2009
22,870
Why do you post the code twice?

Look at the error messages. It says clearly that:

delay
lcd_init
lcdcmd
lcddata
msgdisplay

are not defined.
 

Thread Starter

Muhamad

Joined Mar 31, 2015
14
You need to find the modules with the functions you need and include them in your project. Where do you think those functions are located? What document did you read that informed you of the existence of those functions. Was it the Keil documentation? Was it some site on the interwebz? Tell us what you're doing so we can help you.
I find the project through this link, I hope you can help me. http://grietinfo.in/projects/MINI/BME/4-DOC-HEART RATE AND TEMPERATURE MEASURING DEVICE.pdf
 

Papabravo

Joined Feb 24, 2006
15,032
You have a couple of choices.
  1. Go back to the site where you found the original program to see if you can locate another module with the required functions.
  2. Write your own functions with those names to duplicate what you cannot find.
That's about it. If you can't do one of those things you're probably well and truly hosed.
I'm sorry but it appears that what you got from them was incomplete. They probably did that for a reason. It was either because the routines are in a standard library somewhere or they just want to mess with you.
 
Last edited:

MrChips

Joined Oct 2, 2009
22,870
Have a heart. The TS is a total newbie to programming and is just copying someone's code wholesale.

TS, look at your #include statements.

#include "lcddisplay.h"

This statement says that you must have an external file called lcddisplay.h and it must be present in your current project folder.
If it is not there then you should have received an error message saying cannot open lcddisplay.h.

Along with that file you would need a file called lcddisplay.c and lcddisplay.o which would contain the text and binaries of the required libraries

If you do not have lcddisplay.h and lcddisplay.c on your computer then you have to write your own or find them on the internet.

You can look at other people's code to see how to write your own.

http://www.edaboard.com/thread292900.html

You can also look at this for 8051 examples:
http://www.ekenrooi.net/lcd/lcd.shtml
 
Last edited:

Papabravo

Joined Feb 24, 2006
15,032
OK, I didn't mean to be heartless, but I also don't believe in sugar coating things. The tone of the posts indicated an expectation that someone could solve his problem. It is an important lesson that what you find on the interwebz may not always meet your expectations. The guys who wrote the original paper were kind enough to provide a schematic of their circuit along with some fluff pictures and descriptions of their hardware. If you can locate the datasheets for the display you have a chance of duplicating their code for the missing modules. In the meantime you can create stubs for the missing functions. What is a stub, you ask?
Code:
void lcddisplay(unsigned char *p)
{
  if (p == NULL) return ;
}
It is a function that does nothing so you can get your program to compile and link without warnings or errors. Once you do that you can set about the task of filling in the stub functions with useful code for your particular hardware.
 

Thread Starter

Muhamad

Joined Mar 31, 2015
14
Have a heart. The TS is a total newbie to programming and is just copying someone's code wholesale.

TS, look at your #include statements.

#include "lcddisplay.h"

This statement says that you must have an external file called lcddisplay.h and it must be present in your current project folder.
If it is not there then you should have received an error message saying cannot open lcddisplay.h.

Along with that file you would need a file called lcddisplay.c and lcddisplay.o which would contain the text and binaries of the required libraries

If you do not have lcddisplay.h and lcddisplay.c on your computer then you have to write your own or find them on the internet.

You can look at other people's code to see how to write your own.

http://www.edaboard.com/thread292900.html

You can also look at this for 8051 examples:
http://www.ekenrooi.net/lcd/lcd.shtml
Thank you.. I cannot find lcddisplay.h and lcddisplay.c on internet and I also don't how to write it because I'm still newbie.
 

Thread Starter

Muhamad

Joined Mar 31, 2015
14
OK, I didn't mean to be heartless, but I also don't believe in sugar coating things. The tone of the posts indicated an expectation that someone could solve his problem. It is an important lesson that what you find on the interwebz may not always meet your expectations. The guys who wrote the original paper were kind enough to provide a schematic of their circuit along with some fluff pictures and descriptions of their hardware. If you can locate the datasheets for the display you have a chance of duplicating their code for the missing modules. In the meantime you can create stubs for the missing functions. What is a stub, you ask?
Code:
void lcddisplay(unsigned char *p)
{
  if (p == NULL) return ;
}
It is a function that does nothing so you can get your program to compile and link without warnings or errors. Once you do that you can set about the task of filling in the stub functions with useful code for your particular hardware.
I still don't know how to make it.. Sorry because I so newbie.
 

MrChips

Joined Oct 2, 2009
22,870
As Papa suggests, remove the #include "lcddisplay.h"

and add to your code:

Code:
void lcd_init(void)
{
}

void lcdcmd(unsigned char value)
{
}

void lcddata(unsigned char c )
{
}

void msgdisplay (unsigned char *p)
{
}

void delay(int d);
{
}
This will allow the code to compile but will not get it working.
 

Papabravo

Joined Feb 24, 2006
15,032
To avoid all warnings about unused formal parameters he my have to include some null statements referencing those parameters in the stubs.
 

Papabravo

Joined Feb 24, 2006
15,032
Yeah. The use of "" around the file says to look for the .h file in the same directory as the source file. If you use angle brackets then the "standard" include directories are examined.
 
Top