ABL electronic PIC16 Personal Computer User Manual


 
In order to get the most from your mikroC compiler, you should be familiar with
certain aspects of PIC MCU. This knowledge is not essential, but it can provide
you a better understanding of PICs’ capabilities and limitations, and their impact
on the code writing.
Types Efficiency
First of all, you should know that PIC’s ALU, which performs arithmetic opera-
tions, is optimized for working with bytes. Although mikroC is capable of han-
dling very complex data types, PIC may choke on them, especially if you are
working on some of the older models. This can dramatically increase the time
needed for performing even simple operations. Universal advice is to use the
smallest possible type in every situation. It applies to all programming in general,
and doubly so with microcontrollers.
When it comes down to calculus, not all PICmicros are of equal performance. For
example, PIC16 family lacks hardware resources to multiply two bytes, so it is
compensated by a software algorithm. On the other hand, PIC18 family has HW
multiplier, and as a result, multiplication works considerably faster.
Nested Calls Limitations
Nested call represents a function call within function body, either to itself (recur-
sive calls) or to another function. Recursive calls, as form of cross-calling, are
unsupported by mikroC due to the PIC’s stack and memory limitations.
mikroC limits the number of non-recursive nested calls to:
- 8 calls for PIC12 family,
- 8 calls for PIC16 family,
- 31 calls for PIC18 family.
The number of allowed nested calls decreases by one if you use any of the follow-
ing operators in the code:
* / %. It further decreases by one if you use interrupt
in the program. If the allowed number of nested calls is exceeded, compiler will
report stack overflow error.
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
30
MikroElektronika:
Development
tools
-
Books
-
Compilers
page
PIC SPECIFICS