User manual

215
mikoPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
Typedef Specier
The specier type introduces a synonym for a specied type. The type declarations are used to construct shorter or
more convenient names for types already dened by the language or declared by the user.
The specier type stands rst in the declaration:
type synonym = <type_denition>;
The type keyword assigns synonym to <type_denition>. The synonym needs to be a valid identier.
A declaration starting with the type specier does not introduce an object or a function of a given type, but rather a
new name for a given type. In other words, the type declaration is identical to a “normal” declaration, but instead of
objects, it declares types. It is a common practice to name custom type identiers with starting capital letter this is
not required by the mikroPascal PRO for dsPIC30/33 and PIC24.
For example:
// Let’s declare a synonym for “byte”
type Distance = byte;
// Now, synonym “Distance” can be used as type identier:
var i : Distance; // declare variable i of byte
Type Qualiers
The type qualiers const and volatile are optional in declarations and do not actually affect the type of declared
object.
Qualier const
The qualier const implies that a declared object will not change its value during runtime. In declarations with the
const qualier all objects need to be initialized.
The mikroPascal PRO for dsPIC30/33 and PIC24 treats objects declared with the const qualier the same as literals
or preprocessor constants. If the user tries to change an object declared with the const qualier compiler will report
an error.
For example:
const PI : byte := 3.14159;
Qualier volatile
The qualier volatile implies that a variable may change its value during runtime independently from the program.
Use the volatile modier to indicate that a variable can be changed by a background routine, an interrupt routine, or I/O
port. Declaring an object to be volatile warns the compiler not to make assumptions concerning the value of an object
while evaluating expressions in which it occurs because the value could be changed at any moment.