Predefined Globals and Constants
To facilitate PIC32 programming, the mikroC PRO for PIC32 implements a number of predefined globals and constants.
All PIC32 SFR registers are implicitly declared as global variables of volatile unsigned int. These identifiers have an external linkage, and are visible in the entire project. When creating a project, the mikroC PRO for PIC32 will include an appropriate (*.c) file from defs folder, containing declarations of available SFR registers and constants (such as PORTB, ADPCFG, etc). All identifiers are in upper case, identical to nomenclature in the Microchip datasheets.
All PIC32 SFR registers are also available as structures with bitfields named identically to the Microchip datasheets in order to facilitate bit access e.g
TRISBbits.TRISB3 = 1.
For a complete set of predefined globals and constants, look for “Defs” in the mikroC PRO for PIC32 installation folder, or probe the Code Assistant for specific letters (Ctrl+Space in the Code Editor).
Predefined project level defines
mikroC PRO for PIC32 provides several predefined project level defines that you can use in your project :
- First one is equal to the name of selected device for the project i.e. if P32MX460F512L is selected device, then P32MX460F512L token will be defined as 1, so it can be used for conditional compilation :
#ifdef P32MX460F512L ... #endif
#ifdef __FOSC__ == 80000 ... #endif
#ifdef __MIKROC_PRO_FOR_pic32__ ... #endif
#if __MIKROC_PRO_FOR_pic32_BUILD__ == 142 ... #endif
What do you think about this topic ? Send us feedback!