Datasheet

ACCESSING INDIVIDUAL BITS
The mikroPascal PRO for AVR allows you to access individual bits of 8-bit variables.
It also supports sbit and bit data types
Accessing Individual Bits Of Variables
To access the individual bits, simply use the direct member selector (.) with a vari-
able, followed by one of identifiers B0, B1, … , B7, or 0, 1, … 7, with 7 being
the most significant bit :
// Clear bit 0 on PORTA
PORTA.B0 := 0;
// Clear bit 5 on PORTB
PORTB.5 := 0;
There is no need of any special declarations. This kind of selective access is an
intrinsic feature of mikroPascal PRO for AVR and can be used anywhere in the
code. Identifiers B0–B7 are not case sensitive and have a specific namespace. You
may override them with your own members
B0–B7 within any given structure.
See Predefined Globals and Constants for more information on register/bit names.
sbit type
The mikroPascal PRO for AVR compiler has sbit data type which provides access
to bit-addressable SFRs. You can access them in several ways:
var LEDA : sbit at PORTA.B0;
var name : sbit at sfr-name.B<bit-position>;
var LEDB : sbit at PORTB.0;
var name : sbit at sfr-name.<bit-position>;
96
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Specifics
mikroPASCAL PRO for AVR
CHAPTER 3