User manual

mikroC PRO for dsPIC
MikroElektronika
141
Predened Globals and Constants
To facilitate dsPIC30/33 and PIC24 programming, the mikroC PRO for dsPIC30/33 and PIC24 implements a number
of predened globals and constants.
All dsPIC30/33 and PIC24 SFR registers are implicitly declared as global variables of volatile unsigned int. These
identiers have an external linkage, and are visible in the entire project. When creating a project, the mikroC PRO for
dsPIC30/33 and PIC24 will include an appropriate (*.c) le from defs folder, containing declarations of available SFR
registers and constants (such as PORTB, ADPCFG, etc). All identiers are in upper case, identical to nomenclature
in the Microchip datasheets. All dsPIC30/33 and PIC24 SFR registers are also available as structures with bitelds
named identically to the Microchip datasheets in order to facilitate bit access e.g
TRISBbits.TRISB3 = 1.
For a complete set of predened globals and constants, look for “Defs” in the mikroC PRO for dsPIC30/33 and PIC24
installation folder, or probe the Code Assistant for specic letters (Ctrl+Space in the Code Editor).
Predened project level denes
mikroC PRO for dsPIC30/33 and PIC24 provides several predened project level denes that you can use in your
project :
- First one is equal to the name of selected device for the project i.e. if P30f4013 is selected device, then P30f4013
token will be dened as 1, so it can be used for conditional compilation :
#ifdef P30F4013
...
#endif
- The second one is value of frequency (in kHz) for which the project is built :
#ifdef __FOSC__ == 80000
...
#endif
- Third one is for identifying mikroC PRO for dsPIC30/33 and PIC24 compiler :
#ifdef __MIKROC_PRO_FOR_DSPIC__
...
#endif
- Fourth one is for identifying the build version. For instance, if a desired build version is 142, user should put this in
his code :
#if __MIKROC_PRO_FOR_DSPIC_BUILD__ == 142
...
#endif
Related topics: Project Level Denes