Keil™, An ARM® Company

Discussion Forum

Error: UNRESOLVED EXTERNAL SYMBOL and REFERENCE MADE TO UNRESOLVED EXTERNAL

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
aykut avci
Posted
16-Feb-2009 09:03 GMT
Toolset
C51
New! Error: UNRESOLVED EXTERNAL SYMBOL and REFERENCE MADE TO UNRESOLVED EXTERNAL

Hello everyone,

I am using Keil uVision2 to write my assembler code. I am always getting the same error. I searhed on Google and everbody says the solution is in the Keil manual but I could not find anything. To make it clear, I would want to say what I did so far.

1. Created a project,
2. Selected Atmel T89C51CC01,
3. Clicked new button and wrote my assembler code,
4. I added .asm code in the project.
5. Compile it and get the warnings.

Here is .plg file:

Build target 'Target 1'
assembling STARTUP.A51...
assembling defa.asm...
linking...

*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    SYMBOL:  ?C_START
    MODULE:  STARTUP.obj (?C_STARTUP)
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  ?C_START
    MODULE:  STARTUP.obj (?C_STARTUP)
    ADDRESS: 000DH
Program Size: data=9.0 xdata=0 code=4131
creating hex file from "my"...
"my" - 0 Error(s), 2 Warning(s).
Read-Only
Author
Andrew Neil
Posted
16-Feb-2009 09:30 GMT
Toolset
C51
New! RE: Error: UNRESOLVED EXTERNAL SYMBOL and REFERENCE MADE TO UNRESOLVED EXTERNAL

Are you mixing 'C' and assembler?

If so, things are far easier if you provide a main() in 'C', and call your assembler from that.

Otherwise, you are going to have to do a lot of work to find out how to manually provide the runtine support required for your 'C' code.

Try putting "unresolved ?C_START" into the 'Search' box on this site; here's just one example:
http://www.keil.com/forum/docs/thread398.asp

Read-Only
Author
Andrew Neil
Posted
16-Feb-2009 09:31 GMT
Toolset
C51
New! RE: Error: UNRESOLVED EXTERNAL SYMBOL and REFERENCE MADE TO UNRESOLVED EXTERNAL

http://www.keil.com/support/docs/1980.htm

Read-Only
Author
aykut avci
Posted
16-Feb-2009 09:40 GMT
Toolset
C51
New! RE: Error: UNRESOLVED EXTERNAL SYMBOL and REFERENCE MADE TO UNRESOLVED EXTERNAL

I am newbie in Keil. I just want to write .asm codes to program my microcontroller. My friends recommend Keil for me. Do I have to write main code? Can't I just add .asm files and compile them?

Read-Only
Author
Andrew Neil
Posted
16-Feb-2009 09:45 GMT
Toolset
C51
New! RE: I just want to write .asm codes

The startup files provided by Keil are for use with 'C' programs - don't use them if you're just writing assembler!

(or, if you do use them, be sure to remove any references to anything to do with 'C' - such as ?C_START)

http://www.keil.com/support/man/docs/c51/c51_ap_startup.htm

Read-Only
Author
aykut avci
Posted
16-Feb-2009 09:49 GMT
Toolset
C51
New! RE: I just want to write .asm codes

Ok. I got it. So, after startup code run, it redirect automatically to my main function. If I want to write .asm codes, I need to use #pragma ASM #pragma ENDASM tags. I have just created a .c file and compile it. I was able to generate .hex file as well. Now, I need to upload this .hex file to my microcontroller using flip. Does this .hex file contain startup code?

Read-Only
Author
Andrew Neil
Posted
16-Feb-2009 10:01 GMT
Toolset
C51
New! RE: I just want to write .asm codes

"So, after startup code run, it redirect automatically to my main function."

But you only need that if you're writing in 'C' - you said you're not using 'C', just assembler?

"If I want to write .asm codes, I need to use #pragma ASM #pragma ENDASM tags."

Only if you are embedding your assembler within 'C' code - which, you said, you're not?

"I have just created a .c file"

Why?? You said you just wanted to write assembler - not 'C'?!

"Does this .hex file contain startup code?"

The Hex file contains whatever your project contained!

Read-Only
Author
aykut avci
Posted
16-Feb-2009 10:21 GMT
Toolset
C51
New! RE: I just want to write .asm codes

Yes I want to write .asm codes but it doesn't matter whether in C or not. Now I am supposed to see some leds are on but not. Could you please clarify me why this is happening?

Here is my code:

void main(void)
{
#pragma ASM
                 mov    18h,#01001010b
                 mov    20h,#00100100b
                 mov    28h,#01010010b
                 mov    30h,#01111111b
                 mov    38h,#00110110b
#pragma ENDASM
}

I can compile it successfully and I upload my .hex file to the microcontroller. Now I read from microcontroller and what I see is

Addr 000200 02 00 10 FF FF FF FF FF FF ...

It generates just 02 00 10 for my whole .hex file. Why it is so small? By the way I set CSEG AT 200h.

Read-Only
Author
Tamir Michael
Posted
16-Feb-2009 10:38 GMT
Toolset
C51
New! RE: I just want to write .asm codes

Yes I want to write .asm codes but it doesn't matter whether in C or not

ok, now I lost you.

Read-Only
Author
Andrew Neil
Posted
16-Feb-2009 10:46 GMT
Toolset
C51
New! Get rid of the 'C'!!

just write in assembler - do not complicate the issue with 'C' !!

I think you probably need to start with a tutorial on the basics of the 8051:

http://www.8052.com/forum/tutorial

See also: http://www.keil.com/books/8051books.asp

And, of course, the so-called "bible" for the 8051:

Chapter 1 - 80C51 Family Architecture:
http://www.nxp.com/acrobat_download/various/80C51_FAM_ARCH_1.pdf

Chapter 2 - 80C51 Family Programmer's Guide and Instruction Set:
http://www.nxp.com/acrobat_download/various/80C51_FAM_PROG_GUIDE_1.pdf

Chapter 3 - 80C51 Family Hardware Description:
http://www.nxp.com/acrobat_download/various/80C51_FAM_HARDWARE_1.pdf

.

                 mov    18h, #01001010b
                 mov    20h, #00100100b
                 mov    28h, #01010010b
                 mov    30h, #01111111b
                 mov    38h, #00110110b


Using the above references, what do you think should be the result of writing to those particular memory locations.

As they say in exam papers, "explain your working"...

Read-Only
Author
aykut avci
Posted
16-Feb-2009 10:54 GMT
Toolset
C51
New! RE: Get rid of the 'C'!!

In this example, I tried to send my .hex file to the microcontroller. In order to correct it, I read data from microcontroller and normally I was supposed to see longer sentences because mov 18h, #01001010b would be converted 20 18 4A. Here, 20 is mov, 18 is 18 and 4A is #01001010b. There were 4 lines in my code but when I read from microcontroller I saw just 02 00 10. I supposed something like that,

20 18 4A 20 20 24 20 28 52 20 30 7F 20 38 36 ...

Read-Only
Author
Andy Neil
Posted
16-Feb-2009 11:23 GMT
Toolset
C51
New! AGAIN: Get rid of the 'C'!!

Just throw that example away - it's not worth keeping!

Start again, from scratch, with a pure assembler project.

BTW: if you're using the free evaluation version, be sure to study the Limitations carefully:

http://www.keil.com/demo/limits.asp

Next Thread | Thread List | Previous Thread Start a Thread | Settings