Exact steps to create a project in MPLAB without harmony

I’ve tried several times to create a project using freertos, but every time i get different errors ans problems. Is there any way to set up that project( including linkers, libraries…) that works always?
Im using a dspic33 but i’ve also tried other models and i get similar errors, i’m not experienced in microcontroller programming.
Thanks.

Hey @andreusenis and welcome to the FreeRTOS Community!
I see that you’re running into some issues with getting started using FreeRTOS with MPLAB. I was wondering if you had tried importing in the existing MPLAB demo located in FreeRTOS/FreeRTOS/Demo/dsPIC_MPLAB as a starting point?
I also did some searching and found an older forum post that you might find useful, which can be found here, as well as another blog post which seems to go over the necessary steps here.
If none of the above answers your questions, or if you’re still blocked, if you could let me know what compiler you’re using and what errors you’re seeing I could try and get a similar setup stood up. From there I can see if I can provide further assistance?

Can you say what the errors are - if we see the problem we may be able to suggest a solution.

My normal process is to use the tool to generate a non-FreeRTOS project, make sure that is working, then add in the required FreeRTOS source files. It isn’t necessary to alter the linker script (in the PIC24 case).

Once the files are building you can copy the main() of any of the demos in the main FreeRTOS download to create tasks and start the scheduler.

Let us know how far you get, and what the issue is next time you a blocked.

I just did the process that @rtel described above and I have 1 task running in the simulator.

  1. Create a new MPLAB project
  2. navigate to the project folder and git clone freertos-kernel into this folder. (you could just copy the folder as well)
  3. inside MPLAB right click on Source Files and select “Add existing items from folders”
  4. select the kernel folder that you just cloned (or copied) (make sure the file filter is .c and .S
  5. inside MPLAB right click on the Header Files and select “Add existing items from folders”
  6. select the kernel folder again. This time change the file filter to header files.
  7. open the new FreeRTOS-Kernel/portable folder that is now in your project and remove from the build ALL the ports that do not apply. Leave the MPLAB/pic24dsPIC folder in place.
  8. Add a FreeRTOSConfig.h to the headers folder. You could copy this one to get started.
  9. Remove the heap implementations that are not needed (only 1 should be in your project). I chose heap_1.c
  10. Select your project properties. Open XC16->XC16 (Global Options) and add the FreeRTOS include folder and the portable folder for the PIC24.
  11. Your project view should look something like this.
  12. Check the FreeRTOSConfig.h settings and adjust the clock speed & total heap size appropriately.j
  13. Add the following to your FreeRTOSConfig.h
#ifndef SIZE_MAX
    #define SIZE_MAX    ( ( size_t ) -1 )
#endif
  1. Add #includej <xc.h> at the top of the FreeRTOSConfig.h. You can remove any #includes that specifically reference a device. xc.h will use the project MCU settings.
  2. Provide a main function. Or use the one I have attached.
    main.c (986 Bytes)

You should be able run this and see count increment every 100msec in the simulator.
When I compile I get one warning related to a cast in heap_1.c

There is no harmony in this project and the port directly access timer 1 to provide the tick interrupt for FreeRTOS.

Good Luck

Hi, I used the exact steps u told me to:
i add an image of the errors im getting.


Thank u all for the help.

Did you include xc.h in your FreeRTOSConfig.h as suggested by @jjulich? Can you share your project?

I hadn’t, but after doing it i stil get errors, I’m sorry but as im a new user i cant attach files nor links. The compiling after it looks like this.


Thanks.

Now you are getting linker error because you are running out of memory. Try reducing the value of configTOTAL_HEAP_SIZE in your FreeRTOSConfig.h.

Also, you should now be able to add link and post files.

I got promoted to basic and now i can share stuff, i hope this makes it easier, i have reduced the heap size down to 252 to get rid of the error, but new errors came up.

There were couple of issues in your project -

  1. You missed including 2 assembly port files in FreeRTOS.
  2. You selected a device with 256 bytes of RAM which is too small. I changed it to a different device in the same family which has 8K of RAM.

Attached is the updated project file.

55556.X.7z (566.2 KB)

Thank you, I really appreciate it.