- Microchip Coupon Codes & Discounts - http://microchipdeals.com -
Different methods setting up Projects under Hi-Tech C and MPLab
Posted By admin On 15. February 2010 @ 07:27 In Tips & Tricks, MPLAB | 1 Comment
From [1] 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 [2] 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 [3] 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
What do you think? email [4] support@microchipc.com.
Article printed from Microchip Coupon Codes & Discounts: http://microchipdeals.com
URL to article: http://microchipdeals.com/2010/02/15/different-methods-setting-up-projects-under-hi-tech-c-and-mplab/
URLs in this post:
[1] http://www.microchipc.com/PIC_tips/PIC_tips_1.php: http://www.microchipc.com/PIC_tips/PIC_tips_1.php
[2] files: http://www.microchipc.com/PIC_tips/PIC_tips_1.php#
[3] programmers: http://www.microchipc.com/PIC_tips/PIC_tips_1.php#
[4] support@microchipc.com: http://microchipdeals.commailto:support@microchipc.com
Click here to print.