|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Calling functions from other documents
In MPLAB, how do I call functions from other files in a project?
Here is my code: Code:
static int counter; counter = Get_Encoder_3_Count(); Here is the function code: Code:
long Get_Encoder_3_Count(void)
{
long count;
INTCONbits.RBIE = 0;
count = Encoder_3_Count;
INTCONbits.RBIE = 1;
return(count);
}
Error - could not find definition of symbol 'Get_Encoder_3_Count' in file 'V:\frc-code-2007-8722\FrcCode_2007_8722\user_routines.o'. Last edited by Kilroy0846 : 03-02-2008 at 00:03. Reason: Added The Error Text |
|
#2
|
|||
|
|||
|
Re: Calling functions from other documents
declare the function reference as external to your source file.
Code:
extern long Get_Encoder_3_Count(void); |
|
#3
|
|||
|
|||
|
Re: Calling functions from other documents
are you #include'ing?
|
|
#4
|
|||
|
|||
|
Re: Calling functions from other documents
I have the both the files encoder.c and encoder.h included. I added the external identifier, but I still get the same error.
Here is my new code: Code:
static int counter; extern long Get_Encoder_3_Count(void); counter = Get_Encoder_3_Count(); |
|
#5
|
||||
|
||||
|
Re: Calling functions from other documents
If you're using more than one function from a file, you could just include that file's header file. Use quotes if it's not a library that comes with the compiler.
#include "myfile.h" |
|
#6
|
|||
|
|||
|
Re: Calling functions from other documents
I Have the code:
#include "encoder.h" #include "encoder.c" located at the top of the document |
|
#7
|
|||
|
|||
|
Re: Calling functions from other documents
It sounds like you haven't set up the encoder stuff correctly. Not all the encoder code is enabled by default. If that's the case then that routine isn't being compiled - its being excluded because ENABLE_ENCODER_3 isn't defined.
There is an encoder_readme.txt file in the documentation directory and there is info in the encoder.h file. Is the ENABLE_ENCODER_3 line in .h un-commented? |
|
#8
|
|||
|
|||
|
Re: Calling functions from other documents
You don't need to include "encoder.c", and in fact, you probably shouldn't.
I don't think that's the problem, but if you include a .c file, you're probably going to get an error about something like multiple declarations of something. The headers tells the file that a function exists somewhere in one of the .c files. The actual code for that function doesn't need to be in the same .c file the function is used in. |
|
#9
|
|||||
|
|||||
|
Re: Calling functions from other documents
Take a few steps back. Undo everything you've tried to do in order to make it work. Read the documentation (I think it's called encoder_readme.txt) that comes with the encoder software. Follow the steps (nine of them, if I recall correctly) to add the code to your project and configure it.
If it still doesn't work, let us know. |
|
#10
|
||||
|
||||
|
Re: Calling functions from other documents
Quote:
Last edited by ShotgunNinja : 03-02-2008 at 19:43. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Calling C functions from EasyC | koenig3456 | Programming | 4 | 27-01-2006 16:03 |
| How Do I Program My RC To Spot One wheel From Going faster than the other | Kyle1010 | Programming | 5 | 12-01-2003 15:30 |
| Stack height Poll (spawn from other thread) | Andrew Rudolph | Chit-Chat | 5 | 07-01-2003 17:15 |
| Legality Issues Regarding Gears From other vendors | kilpatrick | Rules/Strategy | 1 | 17-02-2002 09:04 |
| And once more from the top... GLORIA! GEFORCE 3! AND OTHER CARDS... | Robby O | 3D Animation and Competition | 1 | 24-01-2002 20:12 |