Em 27/8/2012 13:48, David escreveu: > On 27/08/2012 17:43, Isaac Marino Bavaresco wrote: >> If your "libraries" are indeed ".lib" files, that approach won't work, >> because the library's code was compiled with a fixed value for the >> constant macros. > They are not .lib files, hence my use of quotes. > > David If you don't need too much speed, you could use a pin abstraction layer. I developed one for a PLC-like application where the pins are operated under control of a remote client sending commands. This is part of file "IO.h": void IOInit ( void ); unsigned char IOGetCount ( void ); signed char IOReadValue ( unsigned char IONumber ); signed char IOSetDirection ( unsigned char IONumber, unsigned char Direction ); signed char IOSetValue ( unsigned char IONumber, unsigned char Value ); signed char IOToggle ( unsigned char IONumber ); signed char IOClear ( unsigned char IONumber ); signed char IOSet ( unsigned char IONumber ); And this is how the pins are associated with numbers: const rom Pin_t IOMap[] =3D { /* Simple digital I/O pins */ P(D,0), P(D,1), P(D,2), P(H,0), P(H,1), P(H,2), P(H,3), P(J,4), P(J,5), P(B,4), P(B,5), P(C,1), P(A,4), P(C,0), /* Analog-capable I/O pins */ P(A,2), P(A,3), P(A,5), P(F,1), P(F,2), P(F,3), P(F,4), P(F,5), P(F,6), P(H,4), P(H,5), P(H,6), P(H,7), /* PWM capable I/O pins */ P(C,2), P(E,6), P(E,5), P(G,4), P(G,0), P(E,4), P(E,3), P(G,3), P(E,7), P(E,2), P(E,1), P(E,0), /* Communication capable I/O pins */ P(C,6), P(C,7), P(G,1), P(G,2), P(C,3), P(C,4), P(C,5), P(F,7), P(B,0), P(B,1), P(B,2), P(B,3) }; Each pin-manipulating function takes around 30 instruction cycles in assembly. First I wrote a C version for reference. This was developed for a PIC18F87J60, by the way. Best regards, Isaac --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .