Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

C code to PIC usable format

Status
Not open for further replies.

knmaheshy2k

Member level 1
Joined
Oct 14, 2005
Messages
37
Helped
7
Reputation
14
Reaction score
5
Trophy points
1,288
Activity points
1,657
Hey guys, i've a C code which is working perfectly fine on my P4.. I need to convert/use the code with PIC16f877.. Pls let me know the procedure.. little urgent it is.. pls help...
 

Ask the right question, mate!

What do you want to do with that piece of C code?

Cheers,
 

Somehow managed to get to know how to work on that c code... now using PCW compiler.. all errors are somehow corrected.. but i'm not able to recognise an error..

Error 160: EXTERNal symbol not found s

this error appears on the last possible line. i dunno what the error is.
 

Sounds like a linker problem. The program has referenced a variable that is to be found in another file at some point in compilation. That is what EXTERN means, it is your promise to the compiler that the variable will be found at some time in compilation, in the meantime the compiler, knowing the storage sixe of the variable, will just leave holes in the code where that variable is referenced and pass that list of holes to the linker which will fill the holes in. Except the varivable is never found, so when the compiler passes off all the object files to the linker which will put in addresses of variables and function and other stuff as needed, there is a varibable that is missing and the linker chokes on it.
 

jhbbunch said:
what EXTERN means, it is your promise to the compiler that the variable will be found at some time in compilation, in the meantime the compiler, knowing the storage sixe of the variable, will just leave holes in the code where that variable is referenced and pass that list of holes to the linker which will fill the holes in. Except the varivable is never found, so when the compiler passes off all the object files to the linker which will put in addresses of variables and function and other stuff as needed, there is a varibable that is missing and the linker chokes on it.
The code code compiles properly if i remove the extern key word.. is it ok??
i've given the snippet of the code below...

#include <16F877a.h>
#include
#include
#use delay (clock=20000000)
#use rs232(baud=115200, xmit=PIN_C6, rcv=PIN_C7, stream=com_1)

#fuses HS,NOWDT,NOPROTECT,NOBROWNOUT,PUT,NOLVP

#byte RCREG=0x1A
#bit CREN=0x18.4
#bit OERR=0x18.1
#bit RCIF=0x0c.5
#bit RCIE=0x8c.5
#bit GIE=0x0b.7
#byte PORTA=0x05

#define serial_error() OERR // USART error
#define serial_fix() {CREN=0;CREN=1;}
#define serial_rx_ready() RCIF

extern byte s[77]; --- here the error comes
extern byte msg[7]; --- here the error comes
extern byte i,l; --- here the error comes
extern byte status1[18]; --- here the error comes
extern byte mloc; --- here the error comes


These extern byte variables are used in the source code file.. i've only one source file which contains 5 functions apart from main..
each function uses one variable... the code compiles properly without errors if i compile it removing the extern keyword.. is it ok if i remove the extern key word and compile???
pls help...
 

if the variables are never referenced (used) in the file then there should be a list of warnings that the variables are declared but never used. But it shouldn't cause the compiler or linker to termnate with an error.
Usually when you have more than one source file you create a project, and you include all files that are going to be used in it as source files. Either that, or you write a big long nasty line in a DOS window when you invoke the compiler. Are all of the source files included in the project?
 

jhbbunch said:
Are all of the source files included in the project?
I've only one source file.. I removed extern key word n now its compiling properly.. hope it works also properly...
 

the source is looking for a static library .lib
or another class where these functions are...

the extern is telling the compiler
it has to use external function to that code class
so removing extern wont help you

you need also the functions sources or .lib etc
 

VSMVDD said:
the source is looking for a static library .lib
or another class where these functions are...

the extern is telling the compiler
it has to use external function to that code class
so removing extern wont help you

you need also the functions sources or .lib etc
all the functions used are included in the same file.. there are no other files... i removed extern and compiled n it compiled properly.. if it compiles properly can i be assured that the program works properly?????
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top