User manual
230
mikoC PRO for dsPIC
MikroElektronika
For example:
/* Let’s declare a synonym for “unsigned long int” */
typedef unsigned long int Distance;
/* Now, synonym “Distance” can be used as type identier: */
Distance i; // declare variable i of unsigned long int
In the typedef declaration, as in any other declaration, several types can be declared at once. For example:
typedef int *Pti, Array[10];
Here, Pti is a synonym for type “pointer to int”, and Array is a synonym for type “array of 10 int elements”.
asm Declaration
The mikroC PRO for dsPIC30/33 and PIC24 allows embedding assembly in the source code by means of the asm
declaration. The declarations _asm and __asm are also allowed in the mikroC PRO for dsPIC30/33 and PIC24 and
have the same meaning. Note that numerals cannnot be used as absolute addresses for SFR or GPR variables in
assembly instructions. Symbolic names may be used instead (listing will display these names as well as addresses).
Assembly instructions can be grouped by the asm keyword (or _asm, or __asm):
asm {
block of assembly instructions
}
The mikroC PRO for dsPIC30/33 and PIC24 comments (both single-line and multi-line) are allowed in embedded
assembly code.
The only types whose name remains the same in asm as it is in the mikroC PRO for dsPIC30/33 and PIC24 are
registers, e.g. INTCON, PORTB, WREG, GIE, etc.
Accessing variables
Depending on the place of declaration, accessing a variable can be done in several ways:
- Accessing global variable:
1. If declared as static (visible only in the le where it was declared):
<source_le_name>_<variable_name>.
2. If declared as a non-static global (visible throughout the whole project): _<variable_name>.
3. If accessing registers (declared through register, rx or sfr speciers, visible throughout the whole
project) : <variable_name>.
- Accessing local variable: <routine_name>_<variable_name>.
- Accessing routine parameter: FARG_<routine_name>_<variable_name>.