SW006010 Microchip Technology, SW006010 Datasheet - Page 81

no-image

SW006010

Manufacturer Part Number
SW006010
Description
MPLAB 17C SOFTWARE
Manufacturer
Microchip Technology
Datasheets

Specifications of SW006010

Tool Function
Compiler
Tool Type
Compiler
Processor Series
PIC17C
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
MPLAB®
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
10.1
10.2
10.3
10.4
 2002 Microchip Technology Inc.
INTRODUCTION
HIGHLIGHTS
STATIC LOCALS AND PARAMETERS
OPTIMIZATION TIPS
This section discusses how to write efficient C code for MPLAB C17.
Items discussed in this chapter are:
• Static Locals And Parameters
• Optimization Tips
Normally, function parameters and local variables have a storage class of
allocated on the stack, and any initializers are executed whenever the function is
invoked. However, it is possible to declare both parameters and local variables to
have static storage class, meaning that they will be allocated globally. This allows for
more efficient code when accessing the variable. When parameters and locals are
declared
• Initializers are only executed once, at application startup.
Therefore, if the function is depending on the variable being freshly initialized at each
function invocation, the initialization must be moved into the function body.
• Initializers must involve values that are known at startup.
For example, a static local variable cannot be assigned a value that involves a
parameter to the function or a function call. The compiler will enforce this restriction.
Because of the limited memory on microcontrollers, optimization becomes an issue as
code complexity increases.
1. Choose the correct memory model for your libraries and precompiled object files.
2. Use the linker script to group variables that are used together into the same data
Use of section pragma’s to effectively manage RAM and ROM. Refer to
7.3 “Processor Header File” for information on the pragma directive. For examples of
use, see the MPLINK linker examples found in the MPASM™ User's Guide with
MPLINK™ and MPLIB™ (DS33014).
Chapter 10. Writing Efficient Code
Don’t just pick the large memory model versions for inclusion in your project.
Consult 5.5 “Memory Models” for more information.
memory bank to minimize bank switching. Intelligent use of the
pragma and the
To minimizing bank switching, place the following in the linker script:
SECTION NAME=coeffs RAM=temperature
and the following in the program:
#pragma varlocate coeff
static
, the following implications arise:
section
directive can yield excellent results.
MPLAB
®
C17 C COMPILER
USER’S GUIDE
varlocate
apRNOVM^-page 75
auto
, are
Part
Part
Part
Part
1
2
3
4

Related parts for SW006010