SW500009 Microchip Technology, SW500009 Datasheet - Page 89

HI-TECH FOR DSPIC/PIC24

SW500009

Manufacturer Part Number
SW500009
Description
HI-TECH FOR DSPIC/PIC24
Manufacturer
Microchip Technology
Type
Compilerr
Series
PIC24 & DsPICr
Datasheet

Specifications of SW500009

Supported Families
PIC24
Core Architecture
PIC, DsPIC
Software Edition
Standard
Kit Contents
Software And Docs
Tool Type
Compiler
Mcu Supported Families
PIC24 MCUs And DsPIC DSCs
Lead Free Status / RoHS Status
Not applicable / RoHS Compliant
For Use With/related Products
DSPIC3X/PIC24
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
Other names
025
778-1003
778-1003
C Language Features
{
}
Compile you program, including this new module and generate an assembly list file, see Section
2.4.17.
name of the function prepended with an underscore. In this example, the label appears on line 37.
37 0002 _read_port:
psect in which the code is located. In this case it is the psect called text.
that contains the definition for read_port() place the following pragma:
will be placed in the psect called readport. Confirm this in the new assembly list file.
to the command-line driver to place this psect at address 0x400.
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
3.12.3.6 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.
The #pragma regsused directive allows the programmer to indicate register usage for functions
that will not be “seen” by the code generator, for example if they were written in assembly code.
unsigned char read_port(void)
Now, how do we know in which psect the code associated with the function will be placed?
Look for the definition of the function. A function starts with an assembly label which is the
36
Look above this to see the first PSECT directive you encounter. This will indicate the name of the
So let us redirect this psect into one with a unique and more meaningful name. In the C module
#pragma psect text=readport
at the top of the module, before the function definition. With this, the read_port() function
Now we can tell the linker where we would like this psect positioned. Issue an additional option
-L-preadport=0400h
The generate an check the map file, see Section 2.4.8. You should see the additional linker
Check the link address to ensure it is that requested, in this case, 0x400.
The general form of the pragma is:
return PORTA;
#pragma regsused register_list
maintext 0
portread 400
Name
psect text
Link Load Length Selector Space Scale
0
400 2
2
0
800
0
0
Preprocessing
75

Related parts for SW500009