User manual
mikroPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
140
sbit type
The mikroPascal PRO for dsPIC30/33 and PIC24 compiler has sbit data type which provides access to bit-addressable
SFRs.
You can declare a sbit varible in a unit in such way that it points to a specic bit in SFR register:
unit MyUnit;
var Abit: sbit; sfr; external; // Abit is precisely dened in some external le, for
example in the main program unit
...
implementation
....
end.
In the main program you have to specify to which register this sbit points to, for example:
program MyProgram;
...
var Abit: sbit at PORTB.0; // this is where Abit is fully dened
...
begin
...
end.
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.
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:
unit MyUnit;
var AnotherBit: sbit; external; // Abit is precisely dened in some external le, for
example in the main program unit
...
implementation
...
end.
program MyProgram;
...
var MyVar: byte;
var Abit: sbit at MyVar.0; // this is where Abit is fully dened
...
begin
...
end.