Personal tools

Creating a new gluon project in Mplab

From Gluonpilot

Jump to: navigation, search

A short overview of the steps you need to take to create a new project on Mplab:

  1. Create a folder. This may look trivial, but you have a lot of options here:
    1. Create one not in the gluon folder: Copy the library in the new folder. Another new folder "src" will hold your code.
    2. Or create one in the gluon folder.
  2. Open Mplab
  3. Choose Project->Project wizard...
  4. Select the correct device (dsPIC33FJ256MC710)
  5. Keep the default C30 toolsuite
  6. "Create a new project file" in the folder you just created.
  7. Don't add any files
  8. Finish the wizard!
  9. Now arrange your windows to your preference. I like the arrangement as shown on the right.
  10. Create a new folder "lib" both under "Source files" and "Header files".
  11. Add the libraries you will need to these folders (at least microcontroller.c and .h, uart1.c and .h).
  12. Create a new .c file with your main code, and add it to the "Source files"
  13. Now configure the project file: Choose Project->Build options->Project
  14. In the directories tab:
    1. Add a new "output directory" called "hex"
    2. Add a new "include search path" thats links to your "lib" directory that contains the libraries. In case of the gluonpilot examples, this is "../../lib".
  15. In MPLAB LINK30: If you wish to use printf(), add a head size of around 128 bytes.
  16. If you wish to use FreeRTOS:
    1. Choose a bigger heap size!
    2. Also add the "FreeRTOS/" library folder to your "include search path"
    3. Add all FreeRTOS library files to your project, preferable in a separate folder called "FreeRTOS". The .asm file should go in your "Source files". Right click -> Assemble
    4. Change the memory model to "large data": Choose Project->Build options->Project -> MPLAB C30 -> Memory model -> Large data model
    5. MPLAB_DSPIC_PORT to the preprocessor macros: Project->Build options->Project -> MPLAB C30 -> Add "MPLAB_DSPIC_PORT" to the preprocessor macros.


A typical minimal main() function looks like:

#include "microcontroller/microcontroller.h"
#include "uart1/uart1.h"
 
int main()
{
microcontroller_init(); // Initialize the microcontroller & PLL
uart1_open(38400l); // Use another baudrate is desired...
 
uart1_puts("Hello world!");
 
// Here the program stops
while (1)
;
}

Gluonpilot
Automating your flight!

Contact page

Products Documentation ForumShop
Copyright (C) Gluonpilot.com