SW500007 Microchip Technology, SW500007 Datasheet - Page 93

PICC-18 PRO

SW500007

Manufacturer Part Number
SW500007
Description
PICC-18 PRO
Manufacturer
Microchip Technology
Type
Compilerr
Series
PIC18r
Datasheets

Specifications of SW500007

Supported Families
PIC18
Core Architecture
PIC
Software Edition
Professional
Kit Contents
Software And Docs
Mcu Supported Families
PIC18
Tool Function
Compiler
Tool Type
Compiler
Lead Free Status / RoHS Status
Not applicable / RoHS Compliant
For Use With/related Products
PIC18 Series
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
Other names
015P
778-1002
778-1002
C Language Features
3.12.3.4 The #pragma regsused Directive
HI-TECH C will automatically save context when an interrupt occurs. The compiler will determine
only those registers and objects which need to be saved for the particular interrupt function defined.
Now, how do we know in which psect the code associated with the function will be
placed? Compile you program, inlcuding this new module and generate an assembly
list file, see Section 2.4.18.
Look for the definition of the function. A function starts with an assembly label which
is the name of the function prepended with an underscore. In this example, the label
appears on line 37.
36
37 0002 _read_port:
Look above this to see the first PSECT directive you encounter. This will indicate the
name of the psect in which the code is located. In this case it is the psect called text.
So let us redirect this psect into one with a unique and more meaningful name. In the C
module that contains the definition for read_port() place the following pragma:
#pragma psect text=readport
at the top of the module, before the function definition. With this, the read_port()
function will be placed in the psect called readport. Confirm this in the new assembly
list file.
Now we can tell the linker where we would like this psect positioned. Issue an additional
option to the command-line driver to place this psect at address 0x400.
-L-preadport=0400h
Then generate and check the map file, see Section 2.4.9. You should see the additional
linker command (minus the leading -L part of the option) present in the section after
Linker command line:. You should also see the remapped psect name appear in the
source file list of psects, e.g.:
/tmp/cgt9e31jr.obj
main.obj
Check the link address to ensure it is that requested, in this case, 0x400.
Name
maintext 0
portread 400
psect text
Link Load Length Selector Space Scale
0
400 2
2
0
800
0
0
Preprocessing
79

Related parts for SW500007