# FreeRTOS v8.2.1 bug in dsPIC33F port.c  pxPortInitialiseStack( ) 

**URL:** <https://forums.freertos.org/t/freertos-v8-2-1-bug-in-dspic33f-port-c-pxportinitialisestack/4228>\
**Category:** Kernel\
**Created:** [August 11, 2015, 6:44pm UTC](https://forums.freertos.org/t/freertos-v8-2-1-bug-in-dspic33f-port-c-pxportinitialisestack/4228 "2015-08-11T18:44:39Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [August 11, 2015, 6:44pm UTC](https://forums.freertos.org/t/freertos-v8-2-1-bug-in-dspic33f-port-c-pxportinitialisestack/4228/1 "2015-08-11T18:44:39Z")

</div>

**[clarkdailey](https://sourceforge.net/u/clarkdailey/)** wrote on [Tuesday, August 11, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/bacd00f5/#0b82):

The port for MPLAB\PIC24\_dsPIC from FreeRTOS v8.2.1 uses a deprecated define “MPLAB\_DSPIC\_PORT”  
in file “port.c”, function “pxPortInitialiseStack” which needs to be defined for the port to work.

To get it to work, either

1. #define MPLAB\_DSPIC\_PORT
2. or remove the two lines  
#ifdef MPLAB\_DSPIC\_PORT  
#endif  
The code should probably be cleaned up to remove the reference to MPLAB\_DSPIC\_PORT.

---

<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:** [August 11, 2015, 7:47pm UTC](https://forums.freertos.org/t/freertos-v8-2-1-bug-in-dspic33f-port-c-pxportinitialisestack/4228/2 "2015-08-11T19:47:12Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Tuesday, August 11, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/bacd00f5/#a1a3):

MPLAB\_DSPIC\_PORT is a FreeRTOS definition that is set in the build configuration within MPLAB. It is not deprecated.

For whatever historic reason, the FreeRTOS PIC24 and dsPIC ports use the same port.c source file, and that definition is used to save additional registers when it is built for use with a dsPIC.

Why do you think this is a bug?

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [August 12, 2015, 12:52am UTC](https://forums.freertos.org/t/freertos-v8-2-1-bug-in-dspic33f-port-c-pxportinitialisestack/4228/3 "2015-08-12T00:52:02Z")

</div>

**[e-christenson](https://sourceforge.net/u/e-christenson/)** wrote on [Wednesday, August 12, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/bacd00f5/#db15):

I’m betting (now don’t you dare let any pesky facts interfere, lol) that MPLAB\_DSPIC\_PORT is used by the newer MPLAB X/Eclipse IDE to allow older MPLAB code to work unmodified…along the lines of some of the earlier ways that config registers were set from within the source code, for example. It will be a few days of other distractions before I can prove my case.

---

<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:** [August 12, 2015, 6:34am UTC](https://forums.freertos.org/t/freertos-v8-2-1-bug-in-dspic33f-port-c-pxportinitialisestack/4228/4 "2015-08-12T06:34:47Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Wednesday, August 12, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/bacd00f5/#771f):

Looking again, I think I understand Clark’s original comments now.

Really old versions of FreeRTOS needed a constant to be defined to allow the kernel code to pull in the header files that were correct for the port being used. That scheme was scrapped some time ago in favour of simply updating the compiler’s include path to include the correct constant - but the constants themselves were kept in the header files for backward compatibility - until the last release when they were moved to a header fle called deprecated\_definitions.h. Although depricated\_definitions.h is included automatically, there is a comment saying the definitions in the file should no longer be used…

…however for the PIC24/dsPIC port (and only that port, as far as I know) the definition _is_ still used for the reason stated in my previous post in this thread. So for that port, the comment is not correct - but the demo project in the FreeRTOS download should still build ok.

Regards.

---

<div class="post-metadata">

**Author:** ![richard-damon](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/richard-damon/32/38_2.png) [@richard-damon](https://forums.freertos.org/u/richard-damon)\
**Post date:** [August 13, 2015, 10:46pm UTC](https://forums.freertos.org/t/freertos-v8-2-1-bug-in-dspic33f-port-c-pxportinitialisestack/4228/5 "2015-08-13T22:46:50Z")

</div>

**[richard\_damon](https://sourceforge.net/u/richard_damon/)** wrote on [Thursday, August 13, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/bacd00f5/#8956):

It should be possible to check on some of the other symbols that the compiler defines to determine the chip family being used.

---

<div class="post-metadata">

**Author:** ![richard-damon](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/richard-damon/32/38_2.png) [@richard-damon](https://forums.freertos.org/u/richard-damon)\
**Post date:** [August 13, 2015, 10:46pm UTC](https://forums.freertos.org/t/freertos-v8-2-1-bug-in-dspic33f-port-c-pxportinitialisestack/4228/6 "2015-08-13T22:46:59Z")

</div>

**[richard\_damon](https://sourceforge.net/u/richard_damon/)** wrote on [Thursday, August 13, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/bacd00f5/#34ea):

It should be possible to check on some of the other symbols that the compiler defines to determine the chip family being used.

---

<div class="post-metadata">

**Author:** ![tlafleur](https://avatars.discourse-cdn.com/v4/letter/t/a6a055/32.png) [@tlafleur](https://forums.freertos.org/u/tlafleur)\
**Post date:** [August 13, 2015, 11:22pm UTC](https://forums.freertos.org/t/freertos-v8-2-1-bug-in-dspic33f-port-c-pxportinitialisestack/4228/7 "2015-08-13T23:22:42Z")

</div>

**[tlafleur](https://sourceforge.net/u/tlafleur/)** wrote on [Thursday, August 13, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/bacd00f5/#8956/8b5b):

The compiler has ifdef defined for each processor and each family group.

---

<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:** [August 14, 2015, 9:49am UTC](https://forums.freertos.org/t/freertos-v8-2-1-bug-in-dspic33f-port-c-pxportinitialisestack/4228/8 "2015-08-14T09:49:21Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Friday, August 14, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/bacd00f5/#b5a9):

The core kernel code should not, ideally, check for individual chips, as it would be a maintenance nightmare. Calling a macro defined in the Microchip header files is find, as it is then up to the Microchip header files to ensure the correct version of the macro is used for the correct chip.

Regards.

---

<div class="post-metadata">

**Author:** ![richard-damon](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/richard-damon/32/38_2.png) [@richard-damon](https://forums.freertos.org/u/richard-damon)\
**Post date:** [August 14, 2015, 11:41am UTC](https://forums.freertos.org/t/freertos-v8-2-1-bug-in-dspic33f-port-c-pxportinitialisestack/4228/9 "2015-08-14T11:41:25Z")

</div>

**[richard\_damon](https://sourceforge.net/u/richard_damon/)** wrote on [Friday, August 14, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/bacd00f5/#2bc8):

It has been a bit since I used it, but as I remember the Microchip compiler defines both a symbol for the specific chip, and a symbol for the family (something like PIC24F or dsPIC33). These symbols could be used by the port layer to determine the exact code to use. These are not defined in a header, but automatically added when you select the chip in the project options.
