Help with dsPIC33FJ128GP802

Hello, I’m trying to use FreeRTOS on my custom board with a Microchip dsPIC33FJ128GP802. The problem is that the demo that comes with the kernel is for the dsPIC33FJ256GP710 chip so it gives me linker errors.

I tried making a project from scratch following this tutorial but the program can´t create tasks unless I use the heap_4.c and even with that file it can’t run the scheduler, it gives me a target halted error. Debbuggin I noticed that the problem is in the xPortStartScheduler() function (inside vTaskStartScheduler()), when it reaches asm volatile ( “return” ) the program freezes.

Does anyone have any advice for this? Also if someone has a simple project for the dsPIC33FJ128GP802 that can share me it would be really helpful and I’d appreciate it a lot.

Thanks for reading. Best regards.

PD: additional information:

  • MPLAB X IDE v5.40
  • FreeRTOS 10.3.1
  • PIC kit 4
  • XC16 v1.50

Do you already have code running without FreeRTOS on the dsPIC33FJ128GP802 to make sure you have the project set up correctly, including the linker script? If so you can then follow the instructions to add in the FreeRTOS code, and use the existing dsPIC33FJ128GP802 project as a reference for include paths, etc. For the heap you can either continue to use the C library heap by making sure it is large enough then including heap_3.c in your project, or you can set the C library heap to zero (or as close to zero as you can get it to link, which may be 4) and then include heap_4.c and ensure configTOTAL_HEAP_SIZE is set adequatly.

Alternatively you can re-target the dsPIC33FJ128GP802 project by changing the compiler settings that define the chip and the linker script to be correct for that chip.


@support@microchip.com
Can you please look into this issue and see if we can help

Thank you for answering. Yes, I have code running on the dsPIC33FJ128GP802 and it works fine (in fact I just don’t start the scheduler and use the main task as a normal function to test the peripherals).

I already have heap_4.c included and set the heap to ( ( size_t ) 1024 * 5 ), in the XC16 configurations I don’t have anything set in the heap size option. I don’t know if I’m doing something wrong.

Tanks again for your help, I will probably try again to re-target the dsPIC33FJ128GP802 project but I couldn’t do it before.

Hello, I’ve found a demo for the dsPIC33F that works. I’ll leave it here in case someone else has the same problem as me, this is the project: github.