Info

You are currently browsing the Microchip Coupon Codes & Discounts weblog archives for the day 15. February 2010.

Calendar
February 2010
S M T W T F S
« Jan   Mar »
 123456
78910111213
14151617181920
21222324252627
28  
Categories

Archive for 15. February 2010

Different methods setting up Projects under Hi-Tech C and MPLab

From http://www.microchipc.com/PIC_tips/PIC_tips_1.php

When it comes to compiling files under Hi-Tech C, there are two methods of doing it. One method is to have a single main.c file, and use #include for all the .c files in the project. Call this the ‘one file with multiple #include of c files’ method.

The second method, also the one usually recommended by C programmers, is to have lots of individual .obj files, and link them at the end. Call this the ‘lots of .obj files’ method.

For the ‘one giant file’ method, in MPLab under ‘node properties’, select ‘PIC C compiler’ for the root node. For the ‘lots of .obj files’ method, select ‘PIC C linker’ for the root node.

The advantages of the ‘one file with multiple #include of c files’ method

Produces smaller .hex file for a large compiled program. For the 16F876/7, there is 8k of program, divided into 4 pages. A psect cannot cross a page boundary. Sometimes there is wasted space before the end of each page boundary. Because the linker has access to all the functions at once, it does a really good job of fitting them in. Try it yourself - get a large (~8k, ~5000 line) program, and it will be smaller using this method.

The advantages of the ‘lots of .obj files’ method

  • This method supports libraries (ie: in MPLab under ‘Edit Project, the ‘library path’ box is enabled.
  • This method supports incremental compiles, which saves a little time, as long as the correct path is entered

What do you think? email support@microchipc.com.

|