what problem with my code using 8051 microcontroller (AT89S52)

Discussion in 'Programmer's Corner' started by Muhamad, Apr 11, 2015.

  1. Muhamad

    Thread Starter New Member

    Mar 31, 2015
    14
    0
    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 (Text):
    1.  
    2. Build target 'Target 1'
    3. linking...
    4. *** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    5.     SYMBOL:  _DELAY
    6.     MODULE:  Project.obj (PROJECT)
    7. *** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    8.     SYMBOL:  _MSGDISPLAY
    9.     MODULE:  Project.obj (PROJECT)
    10. *** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    11.     SYMBOL:  LCD_INIT
    12.     MODULE:  Project.obj (PROJECT)
    13. *** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    14.     SYMBOL:  _LCDDATA
    15.     MODULE:  Project.obj (PROJECT)
    16. *** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    17.     SYMBOL:  _LCDCMD
    18.     MODULE:  Project.obj (PROJECT)
    19. *** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    20.     SYMBOL:  LCD_INIT
    21.     MODULE:  Project.obj (PROJECT)
    22.     ADDRESS: 0805H
    23. *** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    24.     SYMBOL:  _LCDCMD
    25.     MODULE:  Project.obj (PROJECT)
    26.     ADDRESS: 080AH
    27. *** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    28.     SYMBOL:  _MSGDISPLAY
    29.     MODULE:  Project.obj (PROJECT)
    30.     ADDRESS: 0813H
    31. *** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    32.     SYMBOL:  _LCDCMD
    33.     MODULE:  Project.obj (PROJECT)
    34.     ADDRESS: 0818H
    35. *** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    36.     SYMBOL:  _MSGDISPLAY
    37.     MODULE:  Project.obj (PROJECT)
    38.     ADDRESS: 0821H
    39. *** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    40.     SYMBOL:  _LCDCMD
    41.     MODULE:  Project.obj (PROJECT)
    42.     ADDRESS: 082DH
    43. *** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    44.     SYMBOL:  _DELAY
    45.     MODULE:  Project.obj (PROJECT)
    46.     ADDRESS: 083CH
    47. *** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    48.     SYMBOL:  _DELAY
    49.     MODULE:  Project.obj (PROJECT)
    50.     ADDRESS: 0845H
    51. *** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    52.     SYMBOL:  _DELAY
    53.     MODULE:  Project.obj (PROJECT)
    54.     ADDRESS: 0854H
    55. *** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    56.     SYMBOL:  _DELAY
    57.     MODULE:  Project.obj (PROJECT)
    58.     ADDRESS: 0863H
    59. *** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    60.     SYMBOL:  _DELAY
    61.     MODULE:  Project.obj (PROJECT)
    62.     ADDRESS: 086FH
    63. *** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    64.     SYMBOL:  _DELAY
    65.     MODULE:  Project.obj (PROJECT)
    66.     ADDRESS: 0889H
    67. *** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    68.     SYMBOL:  _LCDCMD
    69.     MODULE:  Project.obj (PROJECT)
    70.     ADDRESS: 088EH
    71. *** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    72.     SYMBOL:  _LCDDATA
    73.     MODULE:  Project.obj (PROJECT)
    74.     ADDRESS: 094FH
    75. *** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    76.     SYMBOL:  _DELAY
    77.     MODULE:  Project.obj (PROJECT)
    78.     ADDRESS: 0956H
    79. *** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    80.     SYMBOL:  _LCDDATA
    81.     MODULE:  Project.obj (PROJECT)
    82.     ADDRESS: 0960H
    83. *** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    84.     SYMBOL:  _DELAY
    85.     MODULE:  Project.obj (PROJECT)
    86.     ADDRESS: 0967H
    87. *** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    88.     SYMBOL:  _LCDDATA
    89.     MODULE:  Project.obj (PROJECT)
    90.     ADDRESS: 0971H
    91. *** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    92.     SYMBOL:  _DELAY
    93.     MODULE:  Project.obj (PROJECT)
    94.     ADDRESS: 0978H
    95. Program Size: data=15.0 xdata=0 code=407
    96. "Project" - 0 Error(s), 24 Warning(s).
    97.  
    This is my code.

    Code (Text):
    1.  
    2. #include<reg51.h>
    3. #include"lcddisplay.h"
    4. #include<intrins.h>
    5. sbit rd = P2^0;
    6. sbit wr = P2^1;
    7. sbit intr = P2^2;
    8. sbit finger = P2^5;
    9. sbit buz = P2^3;
    10. #define adcdata P3
    11. void convert(unsigned char );
    12. void lcd_init(void);
    13. void lcdcmd(unsigned char value);
    14. void msgdisplay (unsigned char*);
    15. void delay(int);
    16. void lcddata(unsigned char );
    17. unsigned char a,pp=0,count=0,i;
    18. void main()
    19. {
    20. buz=0;
    21. finger=1;
    22. lcd_init();
    23. lcdcmd(0x85);
    24. msgdisplay("WELCOME");
    25. lcdcmd(0x01);
    26. msgdisplay("temp hbeat");
    27. rd=1;
    28. intr=1;
    29. adcdata=0xff;
    30. while(1)
    31. {
    32. lcdcmd(0xc2);
    33. //delay(500);
    34. wr=0;
    35. _nop_();
    36. _nop_();
    37. _nop_();
    38. _nop_();
    39. wr=1;
    40. delay(50);
    41. rd=0;
    42. delay(10);
    43. a=adcdata;
    44. convert(a);
    45. delay(500);
    46. for(i=0;i<100;i++)
    47. {
    48. count+=1;
    49. if(finger==0)
    50. {
    51. delay(1000);
    52. if(!finger)
    53. {
    54. buz=1;
    55. delay(500);
    56. pp=1;
    57. buz=0;
    58. break;
    59. }
    60. else
    61. pp=0;
    62. }
    63. }
    64. delay(500);
    65. lcdcmd(0xca);
    66. if(pp)
    67. {
    68. convert(count);
    69. }
    70. else
    71. convert(0);
    72. pp=0;
    73. }
    74. }
    75. void convert(unsigned char temp_value)
    76. {
    77. unsigned char value,d1,d2,d3;
    78. temp_value = temp_value;
    79. value=temp_value/10;
    80. d3=temp_value%10;
    81. d1=value/10;
    82. d2=value%10;
    83. d1=d1+0x30;
    84. lcddata(d1);
    85. delay(10);
    86. d2=d2+0x30;
    87. lcddata(d2);
    88. delay(4);
    89. // msgdisplay(".");
    90. d3=d3+0x30;
    91. lcddata(d3);
    92. delay(10);
    93. }
    94.  
    95. #include<reg51.h>
    96. #include"lcddisplay.h"
    97. #include<intrins.h>
    98. sbit rd = P2^0;
    99. sbit wr = P2^1;
    100. sbit intr = P2^2;
    101. sbit finger = P2^5;
    102. sbit buz = P2^3;
    103. #define adcdata P3
    104. void convert(unsigned char );
    105. void lcd_init(void);
    106. void lcdcmd(unsigned char value);
    107. void msgdisplay (unsigned char*);
    108. void delay(int);
    109. void lcddata(unsigned char );
    110. unsigned char a,pp=0,count=0,i;
    111. void main()
    112. {
    113. buz=0;
    114. finger=1;
    115. lcd_init();
    116. lcdcmd(0x85);
    117. msgdisplay("WELCOME");
    118. lcdcmd(0x01);
    119. msgdisplay("temp hbeat");
    120. rd=1;
    121. intr=1;
    122. adcdata=0xff;
    123. while(1)
    124. {
    125. lcdcmd(0xc2);
    126. //delay(500);
    127. wr=0;
    128. _nop_();
    129. _nop_();
    130. _nop_();
    131. _nop_();
    132. wr=1;
    133. delay(50);
    134. rd=0;
    135. delay(10);
    136. a=adcdata;
    137. convert(a);
    138. delay(500);
    139. for(i=0;i<100;i++)
    140. {
    141. count+=1;
    142. if(finger==0)
    143. {
    144. delay(1000);
    145. if(!finger)
    146. {
    147. buz=1;
    148. delay(500);
    149. pp=1;
    150. buz=0;
    151. break;
    152. }
    153. else
    154. pp=0;
    155. }
    156. }
    157. delay(500);
    158. lcdcmd(0xca);
    159. if(pp)
    160. {
    161. convert(count);
    162. }
    163. else
    164. convert(0);
    165. pp=0;
    166. }
    167. }
    168. void convert(unsigned char temp_value)
    169. {
    170. unsigned char value,d1,d2,d3;
    171. temp_value = temp_value;
    172. value=temp_value/10;
    173. d3=temp_value%10;
    174. d1=value/10;
    175. d2=value%10;
    176. d1=d1+0x30;
    177. lcddata(d1);
    178. delay(10);
    179. d2=d2+0x30;
    180. lcddata(d2);
    181. delay(4);
    182. // msgdisplay(".");
    183. d3=d3+0x30;
    184. lcddata(d3);
    185. delay(10);
    186. }
    187.  
    Moderators note : Please use code tags for pieces of code.
     
    Last edited by a moderator: Apr 11, 2015
  2. Papabravo

    Expert

    Feb 24, 2006
    10,136
    1,786
    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.
     
    Ashwin Ashu likes this.
  3. Muhamad

    Thread Starter New Member

    Mar 31, 2015
    14
    0
    How can I fix it? I don't what should i do because i still newbie with proggramming.
     
  4. Papabravo

    Expert

    Feb 24, 2006
    10,136
    1,786
    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.
     
  5. MrChips

    Moderator

    Oct 2, 2009
    12,421
    3,357
    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.
     
  6. Muhamad

    Thread Starter New Member

    Mar 31, 2015
    14
    0
    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
     
  7. Muhamad

    Thread Starter New Member

    Mar 31, 2015
    14
    0
    I'm sorry for not noticing it. How can I defined it?
     
  8. Papabravo

    Expert

    Feb 24, 2006
    10,136
    1,786
    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: Apr 11, 2015
  9. MrChips

    Moderator

    Oct 2, 2009
    12,421
    3,357
    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: Apr 11, 2015
  10. Papabravo

    Expert

    Feb 24, 2006
    10,136
    1,786
    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 (Text):
    1.  
    2. void lcddisplay(unsigned char *p)
    3. {
    4.   if (p == NULL) return ;
    5. }
    6.  
    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.
     
    cmartinez likes this.
  11. Muhamad

    Thread Starter New Member

    Mar 31, 2015
    14
    0
    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.
     
  12. Muhamad

    Thread Starter New Member

    Mar 31, 2015
    14
    0
    I still don't know how to make it.. Sorry because I so newbie.
     
  13. MrChips

    Moderator

    Oct 2, 2009
    12,421
    3,357
    As Papa suggests, remove the #include "lcddisplay.h"

    and add to your code:

    Code (Text):
    1.  
    2. void lcd_init(void)
    3. {
    4. }
    5.  
    6. void lcdcmd(unsigned char value)
    7. {
    8. }
    9.  
    10. void lcddata(unsigned char c )
    11. {
    12. }
    13.  
    14. void msgdisplay (unsigned char *p)
    15. {
    16. }
    17.  
    18. void delay(int d);
    19. {
    20. }
    21.  
    This will allow the code to compile but will not get it working.
     
  14. Papabravo

    Expert

    Feb 24, 2006
    10,136
    1,786
    To avoid all warnings about unused formal parameters he my have to include some null statements referencing those parameters in the stubs.
     
  15. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,383
    495
    Anybody see a problem?
     
  16. Papabravo

    Expert

    Feb 24, 2006
    10,136
    1,786
    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.
     
  17. ScottWang

    Moderator

    Aug 23, 2012
    4,853
    767
    Last edited: Apr 11, 2015
    JohnInTX likes this.
  18. Muhamad

    Thread Starter New Member

    Mar 31, 2015
    14
    0
    an example like what?
     
  19. Muhamad

    Thread Starter New Member

    Mar 31, 2015
    14
    0
  20. Papabravo

    Expert

    Feb 24, 2006
    10,136
    1,786
    Like the example in post #10. You need to read carefully and understand the replies, otherwise there is no point in making the effort to answer your questions.
     
Loading...