I have to edit the content of PORTXbits.RXY with X and Y that can vary (known at compilation but vary in the code). I would like to be able to write someting like PORTBIT(X, Y) = 1; with X defined unsing a define to only have to change it one time in the code.
I have written
#define X A
#define Z B
#define PORTBIT(X, Y) PORT ##Xbits.R ##X ##Y
PORTBIT(X, 0) = 1; // => PORTXbits.RX0 = 1; I want PORTAbits.RA0 = 1;
PORTBIT(Z, 0) = 1; // => PORTZbits.RZ0 = 1;
thats works BUT X is never replaced because the preprocessor replace as it go trough the code, so PORTBIT is replaced before.
Is there anyway to accomplish this replacement before ?