mikroC
making it simple...
Predefined Globals and Constants
To facilitate PIC programming, mikroC implements a number of predefined glob-
als and constants.
All PIC SFR registers are implicitly declared as global variables of
unsigned short
entire project. When creating a project, mikroC will include an appropriate .def
file, containing declarations of available SFR and constants (such as
etc). Identifiers are all in uppercase, identical to nomenclature in Microchip
datasheets. For the complete set of predefined globals and constants, look for
"Defs" in your mikroC installation folder, or probe the Code Assistant for specific
letters (Ctrl+Space in Editor).
Device Clock Constants
There are two built-in constants related to device clock:
Constant
while
where in the code, and are automatically updated as you change target PIC in your
project. Source files that use these constants are recompiled any time the clock is
changed in IDE.
Accessing Individual Bits
mikroC allows you to access individual bits of 8-bit variables, types
unsigned short
followed by one of identifiers
// If RB0 is set, set RC0:
if (PORTB.F0) PORTC.F0 = 1;
There is no need for any special declarations; this kind of selective access is an
intrinsic feature of mikroC and can be used anywhere in the code. Identifiers
–
F0
Provided you are familiar with the particular chip, you can access bits by their
name:
INTCON.TMR0F = 0;
MikroElektronika: Development tools - Books - Compilers
. These identifiers have external linkage, and are visible in the
equals the frequency that is provided by an external oscillator,
___FOSC
is the operating frequency of PIC. Both constants can be used any-
___FCY
. Simply use the direct member selector (
are not case sensitive and have a specific namespace.
F7
// Clear TMR0F
mikroC - C Compiler for Microchip PIC microcontrollers
,
, ... ,
. For example:
F0
F1
F7
volatile
,
T0IE
INTF
and
.
___FOSC
___FCY
and
char
) with a variable,
.
,
page
33
Need help?
Do you have a question about the PIC Microcontrollers PIC12 and is the answer not in the manual?