7.2.1 Register Definition Files
The processor header files described in the previous section name all SFRs for each part, but they do not define the addresses of the SFRs. A separate set of device-specific linker script files, one per part, is distributed in Device Family Packs or DFPs, also mentioned in the previous section. These linker script files define the SFR addresses. To use one of these files, specify the linker command-line option:
-T pdevice.gld
where device corresponds to an
abbreviated device number.
For example, assuming that there is a file named app504.c
that contains an application for the dsPIC33EP512MC504 part, then it may be compiled and
linked using the following commands:
set DFP_XCDSC="C:/Program Files/Microchip/MPLABX/v6.30/packs/Microchip/dsPIC33E-GM-GP-MC-GU-MU_DFP/1.6.297/xc16"
xc-dsc-gcc -mcpu=33EP512MC504 -mdfp=%DFP_XCDSC% -o app504.out -T p33EP512MC504.gld -c app504.c
where:
-mcpuspecifies the device name in an abbreviated format.-mdfpspecifies the path to the DFP for the device.-onames the output executable file asapp504.out.-Tprovides the linker script name for the device.-cis the C code application file nameapp504.c.
It is unlikely that you will need to customize a linker script but if you do, you should:
- Copy the linker script file from the appropriate DFP into your project directory before any project-specific modifications are made.
- Edit the copied linker script (which is a text file).
- Make sure to pass the custom linker
script explicitly when compiling and linking, i.e.,
-T my_p33EP512MC504.gld.
