Forum : 8051
Original Post
Post Information | Post |
---|---|
August 15, 2012 - 5:59pm
|
I created the LIB file with define PORT How can I define the PORT from my project |
Forum : 8051
Post Information | Post |
---|---|
August 15, 2012 - 5:59pm
|
I created the LIB file with define PORT How can I define the PORT from my project |
Hello,
Could you please clarify what you mean by "define the PORT"?
I imagine several possible things it could mean. (#define, global variable, symbol for peripheral register, etc.)
Best Regards,
Vincent
example
sbit X=P1^1;
Hello,
Just put this in the header (.h) file, not in the C (.c) file.
And of course include the header file in the other files of the project, not just in the files of the library.
Best Regards,
Vincent
A little late, but if i create lib example
c file
#include
void fun1(void)
{
x=0;
}
h file
#include
void fun1(void);
sbit x=P1^7;
and i had the file.lib in my project
c file
#include
#include
void main(void)
{
while(1)
fun1();
}
and h file with another define P1.0
#include
void fun1(void);
sbit x=P1^0;
I get P1.7 when I want change from my project P1.0
A little late, but if i create lib example
c file
#include
void fun1(void)
{
x=0;
}
h file
#include
void fun1(void);
sbit x=P1^7;
and i had the file.lib in my project
c file
#include
#include
void main(void)
{
while(1)
fun1();
}
and h file with another define P1.0
#include
void fun1(void);
sbit x=P1^0;
I get P1.7 when I want change from my project P1.0
Hello,
If you get P1.7 for sbit x rather than P1.0, it means that the last definition reached by the compiler while reading the include files defines x as P1.7
To resolve your problem, be careful with the include file order.
Regards,
Stéphane
I get definition from lib file only
when I want from my project
.lib files are used on link, not on compilation.
So there is probably a .h file (likely related to the lib) that you include in your project's files and that contains the lib's definition of x.
You should place the lib's definition in a h file that is included in the sources of the lib but _not_ in the sources of the calling project.