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:

  • -mcpu specifies the device name in an abbreviated format.
  • -mdfp specifies the path to the DFP for the device.
  • -o names the output executable file as app504.out.
  • -T provides the linker script name for the device.
  • -c is the C code application file name app504.c.

It is unlikely that you will need to customize a linker script but if you do, you should:

  1. Copy the linker script file from the appropriate DFP into your project directory before any project-specific modifications are made.
  2. Edit the copied linker script (which is a text file).
  3. Make sure to pass the custom linker script explicitly when compiling and linking, i.e., -T my_p33EP512MC504.gld.