User manual
mikroC PRO for dsPIC
MikroElektronika
143
Note : If aiming at portability, avoid this style of accessing individual bits, use the bit elds instead.
See Predened Globals and Constants for more information on register/bit names.
sbit type
The mikroC PRO for dsPIC30/33 and PIC24 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 specic bit in SFR register:
extern sfr sbit Abit; // Abit is precisely dened 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 dened
...
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 dened as a sfr variable.
Note : Declaring a sbit variable is not possible via F0, F1, … F15 identiers.
In case we want to declare a bit over a variable which is not dened as sfr, then the keyword sfr is not necessary,
for example:
extern sbit AnotherBit; // AnotherBit is precisely dened in some external le, for
example in the main program unit
char MyVar;
sbit AnotherBit at MyVar.B0; // this is where AnotherBit is fully dened
...
void main() {
...
}