mikroC

mikroC - C Compiler for Microchip PIC microcontrollers

making it simple...

PIC SPECIFICS

page

30

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 handling 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 following 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.

MikroElektronika: Development tools - Books - Compilers