# Help with dsPIC33FJ128GP802

**URL:** <https://forums.freertos.org/t/help-with-dspic33fj128gp802/10272>\
**Category:** Microchip\
**Created:** [July 16, 2020, 12:42pm UTC](https://forums.freertos.org/t/help-with-dspic33fj128gp802/10272 "2020-07-16T12:42:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![maurofm](https://avatars.discourse-cdn.com/v4/letter/m/7993a0/32.png) [@maurofm](https://forums.freertos.org/u/maurofm)\
**Post date:** [July 16, 2020, 12:42pm UTC](https://forums.freertos.org/t/help-with-dspic33fj128gp802/10272/1 "2020-07-16T12:42:56Z")

</div>

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](https://www.freertos.org/Creating-a-new-FreeRTOS-project.html) 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

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [July 16, 2020, 3:24pm UTC](https://forums.freertos.org/t/help-with-dspic33fj128gp802/10272/2 "2020-07-16T15:24:43Z")

</div>

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.

> **[Creating a new RTOS project](https://www.freertos.org/Creating-a-new-FreeRTOS-project.html)**
>
> Create and use an RTOS project

  

> **[FreeRTOS - Porting a FreeRTOS demo to a different hardware platform](https://www.freertos.org/porting-a-freertos-demo-to-different-hardware.html)**
>
> FreeRTOS is a portable, open source, mini Real Time kernel. A free RTOS for small embedded systems

---

<div class="post-metadata">

**Author:** ![Shridhar](https://avatars.discourse-cdn.com/v4/letter/s/858c86/32.png) [@Shridhar](https://forums.freertos.org/u/Shridhar)\
**Post date:** [July 16, 2020, 4:53pm UTC](https://forums.freertos.org/t/help-with-dspic33fj128gp802/10272/3 "2020-07-16T16:53:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![maurofm](https://avatars.discourse-cdn.com/v4/letter/m/7993a0/32.png) [@maurofm](https://forums.freertos.org/u/maurofm)\
**Post date:** [July 16, 2020, 6:21pm UTC](https://forums.freertos.org/t/help-with-dspic33fj128gp802/10272/4 "2020-07-16T18:21:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![maurofm](https://avatars.discourse-cdn.com/v4/letter/m/7993a0/32.png) [@maurofm](https://forums.freertos.org/u/maurofm)\
**Post date:** [July 21, 2020, 7:07pm UTC](https://forums.freertos.org/t/help-with-dspic33fj128gp802/10272/5 "2020-07-21T19:07:06Z")

</div>

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](https://github.com/MicrochipTech/freeRTOS-PIC24-dsPIC-PIC32MM).

---

<div class="post-metadata">

**Author:** ![Deontae](https://avatars.discourse-cdn.com/v4/letter/d/7ba0ec/32.png) [@Deontae](https://forums.freertos.org/u/Deontae)\
**Post date:** [September 2, 2021, 6:37am UTC](https://forums.freertos.org/t/help-with-dspic33fj128gp802/10272/6 "2021-09-02T06:37:07Z")

</div>

Thanks for the information. Keep sharing such informative post. Keep suggesting such post.
