Personal tools
Creating a new gluon project in Mplab
From Gluonpilot
A short overview of the steps you need to take to create a new project on Mplab:
- Create a folder. This may look trivial, but you have a lot of options here:
- Create one not in the gluon folder: Copy the library in the new folder. Another new folder "src" will hold your code.
- Or create one in the gluon folder.
- Open Mplab
- Choose Project->Project wizard...
- Select the correct device (dsPIC33FJ256MC710)
- Keep the default C30 toolsuite
- "Create a new project file" in the folder you just created.
- Don't add any files
- Finish the wizard!
- Now arrange your windows to your preference. I like the arrangement as shown on the right.
- Create a new folder "lib" both under "Source files" and "Header files".
- Add the libraries you will need to these folders (at least microcontroller.c and .h, uart1.c and .h).
- Create a new .c file with your main code, and add it to the "Source files"
- Now configure the project file: Choose Project->Build options->Project
- In the directories tab:
- Add a new "output directory" called "hex"
- 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".
- In MPLAB LINK30: If you wish to use printf(), add a head size of around 128 bytes.
- If you wish to use FreeRTOS:
- Choose a bigger heap size!
- Also add the "FreeRTOS/" library folder to your "include search path"
- 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
- Change the memory model to "large data": Choose Project->Build options->Project -> MPLAB C30 -> Memory model -> Large data model
- 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)
;
}