View Single Post
  #1   Spotlight this post!  
Unread 30-12-2006, 02:16
Cjmovie's Avatar
Cjmovie Cjmovie is offline
1293 Resident Hacker
AKA: Christopher Corsi
FRC #1293 (D5 Robotics)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2006
Location: SC
Posts: 73
Cjmovie is a name known to allCjmovie is a name known to allCjmovie is a name known to allCjmovie is a name known to allCjmovie is a name known to allCjmovie is a name known to all
Code::Blocks IDE interface (Tutorial/Makefile)

Hello,

After having a lot of problems with the interface in MPLAB, I decided to find a way to use my choice IDE of Code::Blocks to program the RC. After many searches and problems, I've managed to create a very nice interface for programming it.
Code::Blocks is a lightweight, opensource editor written in C++ with the wxWidgets toolkit. It's available for any operating system wxWidgets supports, although you're still tied to windows for the MPLAB C18 Compiler. It can be found at http://codeblocks.org/
My setup uses a custom makefile based on one I've had from long ago, originally written for Eclipse. I'm not sure of the author, but I cannot take full credit for it. However, I have customized it for use with Code::Blocks to take advantage of a really cool feature: Using the drop-down box in the IDE, you can change code between the 18F8722 and 18F8520 processor. It automatically switches out all libraries and build options. You can, in fact, compile it for one and then the other, without running a clean or anything. It will also keep the HEX output files named according to processor. Probably handy for when you need to run something on both models.

To use this setup, the MPLAB C18 compiler must be installed with the PATH environment variable pointing to the compiler's directory. Also, Code::Blocks must be installed, of course. I've only tested this with the 1.0rc2 on the main website.
The instructions for using this interface are as follows:

1. Download the makefile on my website and save it in the same directory as your code. After you've put the makefile in there, create two new folders: "obj.8722" and "obj.8520". Also, rename the libraries for the 8722 PIC to FRC_Library_8722.lib, and the library for the 8520 to FRC_Library_8520.lib.
2. Create a new Code::Blocks project, add all of your *.c and *.h files to it, and save the project in the same place as your code
3. In your project, add the 2 build targets PIC18F8722 and PIC18F8520. You can do this by clicking Project->Properties on the menu bar and clicking the "Targets" tab.
4. Now, leaving that dialog open, click the "Project" tab. Check the box that says "This is a custom Makefile" and make sure the makefile name matches the name of the makefile ("Makefile")
5. Click OK to close the window
6. Click Build->Options on the menu bar. Go to the "Other" tab, and click the drop-down box labeled "Build Method". Select "Work with Makefiles (GNU make is required)".
7. Click OK to close the window
8. On the drop-down box on the toolbar of the editor, labeled "Build target", select your processor of choice
9. Click "Build" either via the "Build" menu or the shortcut button on the toolbar.
10. Done! Just use the IFI_Loader applicatoin to download either PIC18F8722.hex or PIC18F8520.hex to your robot controller.

(Note: The makefile also defaults to having the MPLAB C18 compiler include directory and library directory in "c:\mcc18\h" and "c:\mcc18\lib". If this isn't what you want, open the makefile with notepad and look at the top 5-ish lines, and change what you need. MPDRIVE changes the hard drive/partition you have it installed on, which is default to C)

If you've got any questions, comments, etc. let me know. If this has been discussed already, I apologize, as a quick forum search didn't come up with it for me when I needed it.

*edit*
I've tested this only with the "make" utility included with Code::Blocks. If you run into errors, make sure that A) you installed Code::Blocks with the compiler it comes with, and B) You have that compiler selected as default. That way it will use the version of GNU make included with Code::Blocks.
__________________
D5 Robotics, Team 1293: Programmer, CAD'er, Mechanical, Electrical... I've made my rounds.
Events: 2006-2009 Palmetto Regional
Website: http://d5robotics.org/

Last edited by Cjmovie : 30-12-2006 at 16:34. Reason: Update instructions