User manual

Table Of Contents
mikroC PRO for PIC32
MikroElektronika
139
Note: If aiming at portability, avoid this style of accessing individual bits, use the bit elds instead.
See Predened Globals and Constants for more information on register/bit names.
sbit type
The mikroC PRO for PIC32 compiler has sbit data type which provides access to registers, SFRs, variables, etc.
You can declare a sbit variable in a unit in such way that it points to a specic bit in SFR register:
extern sfr sbit Abit; // Abit is precisely dened in some external le, for example in
the main program unit
In the main program you have to specify to which register this sbit points to, for example:
sbit Abit at PORTB.B0; // this is where Abit is fully dened
...
void main() {
...
}
In this way the variable Abit will actually point to PORTB.0. Please note that we used the keyword sfr for declaration
of Abit, because we are pointing it to PORTB which is dened as a sfr variable.
Note: Declaring a sbit variable is not possible via F0, F1, … F31 identiers.
In case we want to declare a bit over a variable which is not dened as sfr, then the keyword sfr is not necessary,
for example:
extern sbit AnotherBit; // AnotherBit is precisely dened in some external le, for
example in the main program unit
char MyVar;
sbit AnotherBit at MyVar.B0; // this is where AnotherBit is fully dened
...
void main() {
...
}