Hello!
In the Test.Lib Library I am creating a function, which set a specific port and pin. The port and pin must be defined in the project to which i have added Test.Lib
In Library Project, I have Test.C
Test.C ======= extern char Port; extern bit pin; void func(unsigned char ch, bit bt) { Port = ch; pin = bt; }
the Test.Lib is successfully compiled and generated the .Lib file. Now I added this .Lib file to my working project. The main file look like this.
main.c ======
#define Port P1 sbit pin = P0^0;
void func(unsigned char ch, bit bt); //Prototype
void main(void) { func(0x55,1); while(1); }
It doest not set the desired values to Port and Pin. Please help me in this regard.
Thanks. with regards. SAJJAD
You are right. But think of developing Library for 8-bit Alpha Numeric LCB. One should have flexiblity of assigning D0-D7, Rs, Rw, E, to different pins of microcontroller. How to do that.
You say "one should have" as if talking about human rights.
But what is your view on the fact that the processor doesn't support indexed access to bit variables, and that the C language was designed for code generation by the compiler - not the linker? That Keil performs some of the code generation in the linker is a nice work-around to processor limitations but shouldn't be seen as any "right" you have.
I have already told you of possible workarounds - having the library function know the different port 8-bit registers and perform logic OR to set a bit or NOT + AND to clear a bit. Or have your program contain functions to set and clear the signals and have the library call these functions in your program. Since the displays are normally slow and requires delays, it shouldn't matter too much that the workarounds requires extra machine cycles compared to inlined operations.
You could always develop it as a source "library"...
"have your program contain functions to set and clear the signals and have the library call these functions"
For an example of this, see how the C51 implementation of the library function printff uses the basic IO funtions:
http://www.keil.com/support/man/docs/c51/c51_printf.htm http://www.keil.com/support/man/docs/c51/c51_ap_basicio.htm