5.7.2 Add a File to the Project

To add a C code template file to the project, follow the steps below.

  1. If this is the first time you have used the XC-DSC toolchain:
    1. Right click on the Source Files folder in the project tree. Select NewOther from the drop-down menu.
    2. In the New File dialog, click to expand the Microchip Embedded category to find and select the toolchain compiler folder.
    3. Under File Types, find and click on the main file. Then click Next to move to the Name and Location step.
  2. If you have used the XC-DSC toolchain before:
    1. Right click on the Source Files folder in the project tree. Select New > mainXC-DSC.c to open the New mainXC-DSC.c dialog to the Name and Location step.
  3. Under File Name, you may change the default newmainXC-DSC.c name if you wish.
  4. Under Folder, enter a folder in which to place the file. The default is the project folder. Keeping the file in the project folder makes the project more portable.
  5. Click Finish.

The project tree should now have the Source Files folder open, containing the file added, as well as the new file open in an Editor window (see following figure).

Note: If you add more than one file, the order in which you add these files to the project is the order in which they will be linked.
Figure 5-4. Project Tree and Source Code