I am using pic16f887 microcontroller and using Hi-tech C compiler. I want to implement port pin's Array in Hi-tech but it is not allowing me to do so. What is the correct way to access pin address with indexing, like we do in arduino.
i want array like
bit * lcd[4]={RA0,RA1,RB0,RC4};
it gives following errors
- arrays of bits or pointers to bit are illegal
- constant expression required
- illegal conversion of integer to pointer
It clearly means I cannot declare Arrays of Bit, what is the other way to access pin numbers via indexing in standard C style or any other compiler related trick.
In header files pins are declared in following manners
// Register: TRISB
volatile unsigned char TRISB @ 0x086;
// bit and bitfield definitions
volatile bit TRISB0 @ ((unsigned)&TRISB*8)+0;
volatile bit TRISB1 @ ((unsigned)&TRISB*8)+1;
volatile bit TRISB2 @ ((unsigned)&TRISB*8)+2;
volatile bit TRISB3 @ ((unsigned)&TRISB*8)+3;
volatile bit TRISB4 @ ((unsigned)&TRISB*8)+4;
volatile bit TRISB5 @ ((unsigned)&TRISB*8)+5;
volatile bit TRISB6 @ ((unsigned)&TRISB*8)+6;
My problem is that, I do not want to name the port I want to index them so that I could call them with their numbers like we do in arduino style
digitalWrite(13,HIGH);
digitalWrite()
. \$\endgroup\$digitalWrite()
has all of this, and it should be trivial to port this to Hi-tech C. \$\endgroup\$