# PIC32 Port Example

**URL:** <https://forums.freertos.org/t/pic32-port-example/1909>\
**Category:** Kernel\
**Created:** [November 24, 2011, 4:43am UTC](https://forums.freertos.org/t/pic32-port-example/1909 "2011-11-24T04:43:58Z")\
**Posts on this page:** 17\
**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:** [November 24, 2011, 4:43am UTC](https://forums.freertos.org/t/pic32-port-example/1909/1 "2011-11-24T04:43:58Z")

</div>

**[joeygo](https://sourceforge.net/u/joeygo/)** wrote on [Thursday, November 24, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/531198e5/#4ac0):

Has anyone successfully got the PIC32 example port going?  
[http://www.freertos.org/index.html?http://www.freertos.org/port\_PIC32\_MIPS\_MK4.html](http://www.freertos.org/index.html?http://www.freertos.org/port_PIC32_MIPS_MK4.html)

Thanks in advance

---

<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:** [November 24, 2011, 4:49am UTC](https://forums.freertos.org/t/pic32-port-example/1909/2 "2011-11-24T04:49:00Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Thursday, November 24, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/531198e5/#0e05):

> Has anyone successfully got the PIC32 example port going?  
> [http://www.freertos.org/index.html?http://www.freertos.org/port\_PIC32\_MIPS\_MK4.html](http://www.freertos.org/index.html?http://www.freertos.org/port_PIC32_MIPS_MK4.html)

Of course.&nbsp;

Your post is very unhelpful.&nbsp; If you are having a problem, it is better to describe the problem, so people can actually suggest a solution.&nbsp; Otherwise you are devaluing this resource.

Please read the the FAQ

[http://www.freertos.org/FAQ-how-to-use-the-FreeRTOS-support-forum.html](http://www.freertos.org/FAQ-how-to-use-the-FreeRTOS-support-forum.html)

You can then choose to either post something helpful to yourself and other users, or not post.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 29, 2011, 1:42am UTC](https://forums.freertos.org/t/pic32-port-example/1909/3 "2011-11-29T01:42:23Z")

</div>

**[joeygo](https://sourceforge.net/u/joeygo/)** wrote on [Tuesday, November 29, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/531198e5/#c178):

Thanks for your reply and confidence in the PIC32 port.

I downloaded the PIC32 port and MPLAB&nbsp; IDE reported the port was written on the older v1.11 c32 PIC32 compiler.

There have been significant changes to the C32 complier as documented here [http://ww1.microchip.com/downloads/en/DeviceDoc/MPLABC32\_v2\_01\_README.html](http://ww1.microchip.com/downloads/en/DeviceDoc/MPLABC32_v2_01_README.html)

QUESTION  
Has the PIC32 port been tested with the “significant” changes in the C32 complier&nbsp; now currently ver2.01?

Thanks in advance&nbsp;&nbsp; Joeygo

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 29, 2011, 1:45am UTC](https://forums.freertos.org/t/pic32-port-example/1909/4 "2011-11-29T01:45:40Z")

</div>

**[joeygo](https://sourceforge.net/u/joeygo/)** wrote on [Tuesday, November 29, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/531198e5/#dbd5):

Sorry&nbsp; and another question… Can / or has the PIC32 Port example been written for complier version independence as much as possible (since the C32 complier is improving in leaps and bounds)

joeygo

---

<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:** [November 29, 2011, 7:46am UTC](https://forums.freertos.org/t/pic32-port-example/1909/5 "2011-11-29T07:46:37Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Tuesday, November 29, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/531198e5/#7088):

The latest FreeRTOS version was tested with whatever the latest version of C32 was at the time it was released, which was V2. something.&nbsp; Please just try it yourself, then come here for support it you have a problem.&nbsp; There is no pre-sales support, as FreeRTOS is not for sale.

> Can / or has the PIC32 Port example been written for complier version independence as much as possible

As much as possible, yes, but there are 14 tool chains supported, and tool chains change all the time.&nbsp; There is no way of predicting what will happen in the future.&nbsp; A few things have changed in the C32 compiler, normally I get pre-warning, but not always.&nbsp; That is why users should report here when there is an issue, so it can be maintained.&nbsp; If every user asked these questions before actually even trying the code, this forum would have millions of posts, and none of them would be answered because there would be no way of keeping up.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 30, 2011, 6:28pm UTC](https://forums.freertos.org/t/pic32-port-example/1909/6 "2011-11-30T18:28:27Z")

</div>

**[crosland](https://sourceforge.net/u/crosland/)** wrote on [Wednesday, November 30, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/531198e5/#b35b):

It works fine in 2.00 which is where the update to the underlying GNU tools was introduced. Changes to 2.01 look minor to me.

What exactly is the problem you see?

Andrew Crosland

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 17, 2012, 6:58pm UTC](https://forums.freertos.org/t/pic32-port-example/1909/7 "2012-01-17T18:58:09Z")

</div>

**[marico](https://sourceforge.net/u/marico/)** wrote on [Tuesday, January 17, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/531198e5/#49c8):

It’s never worked for me. I tried before (about one year ago) and I gave up. Now I try to make it work again with version 7.1.0 and I got the same poor results.  
My test freertos app always fail with alignment exception. My source is very simple: just 2 tasks doing nothing (infinite while loop). I tried all possible heap\_x implementation, same results. Exceptions always occur when calling gvTaskStartScheduler(), exception is&nbsp; in vPortStartFirstTask&nbsp; at .line:  
&nbsp; lw&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s6,8(s5)  
(portRESTORE\_CONTEXT code)  
My toolchain: gcc version 3.4.4&nbsp;&nbsp; Microchip MPLAB C Compiler for PIC32 MCUs v1.11-20100413

Marico

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 17, 2012, 8:02pm UTC](https://forums.freertos.org/t/pic32-port-example/1909/8 "2012-01-17T20:02:09Z")

</div>

**[edwards3](https://sourceforge.net/u/edwards3/)** wrote on [Tuesday, January 17, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/531198e5/#ca77):

What did you use as a base for your project? There are a few PIC32 applications around that work with no problem if you have the same hardware that the application was written for. If you switch hardware you might have to change something, but you can use the same project as a start. Microchip even have an application note with some project files about using FreeRTOS with their free libraries, you could try those too.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 17, 2012, 9:38pm UTC](https://forums.freertos.org/t/pic32-port-example/1909/9 "2012-01-17T21:38:33Z")

</div>

**[marico](https://sourceforge.net/u/marico/)** wrote on [Tuesday, January 17, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/531198e5/#459c):

I use simple diy pic32 test board with uart1 connected to a PC (I use uart1 for dubbuging messages). My freertos app has two task, one task should write ‘A’ char to uart1 and task2 should write ‘B’ (both tasks do it in a infinite loop).  
After initailizing the hardware (SYSTEMConfigPerformance,uart1,etc) I call:  
&nbsp; INTEnableSystemMultiVectoredInt();  
portDISABLE\_INTERRUPTS();  
xTaskCreate( prvTestTask1, ( const signed char \* const ) “Tst1”,configMINIMAL\_STACK\_SIZE, NULL, tskIDLE\_PRIORITY, NULL );  
xTaskCreate( prvTestTask2, ( const signed char \* const ) “Tst2”, configMINIMAL\_STACK\_SIZE, NULL, tskIDLE\_PRIORITY, NULL );  
vTaskStartScheduler();

and after one second after calling vTaskStartScheduler(); I got exception:  
General Exception&nbsp; bus error (load/store)&nbsp; at a00010e4

And, of course, there is no life signs from task1 or task2 (even in that one second after vTaskStartScheduler call and exception occur).

Is there exist a simple pic32 freertos demo with only 2 task and hardware board independend? PIC32 demo included in freertos source is complex, huge and hard to understand (and focused only to a specified hardware and mplab).&nbsp;  
Till now i figured out, that maybe there is a problem with vT1InterruptHandler, which is never called. I rerouted T1 interrupt to tempoerary ISR to test it, and&nbsp; T1 int.&nbsp; works only when I remove&nbsp; portDISABLE\_INTERRUPTS(); from my code.  
But without portDISABLE\_INTERRUPTS(); I got other exception:  
General Exception&nbsp; bus error (load/store)&nbsp; at 0  
(looks liike a null pointer?)  
Do I have to always portDISABLE\_INTERRUPTS(); after INTEnableSystemMultiVectoredInt()?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 21, 2012, 9:31pm UTC](https://forums.freertos.org/t/pic32-port-example/1909/10 "2012-01-21T21:31:48Z")

</div>

**[marico](https://sourceforge.net/u/marico/)** wrote on [Saturday, January 21, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/531198e5/#ecdf):

OK, I figured out where the problem was, in the port.c file there is a variable with initial value:  
volatile unsigned portBASE\_TYPE uxInterruptNesting = 0x01;

for uknown reason my pic32mx-gcc won’t initialize variables declared out of functions scope, so&nbsp; in&nbsp; vPortStartFirstTask() call uxInterruptNesting was -1 (instead of 1).&nbsp;

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 21, 2012, 9:39pm UTC](https://forums.freertos.org/t/pic32-port-example/1909/11 "2012-01-21T21:39:05Z")

</div>

**[edwards3](https://sourceforge.net/u/edwards3/)** wrote on [Saturday, January 21, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/531198e5/#367c):

Sounds like you are using a bum start up file. I would recommend fixing that so it sets up the C run time environment properly before getting too deep into your project because you don’t know how many variables have the wrong values.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 3, 2012, 3:57pm UTC](https://forums.freertos.org/t/pic32-port-example/1909/12 "2012-02-03T15:57:16Z")

</div>

**[erupter](https://sourceforge.net/u/erupter/)** wrote on [Friday, February 03, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/531198e5/#f8a5):

[http://www.joaomelo.hydroimprovement.com/](http://www.joaomelo.hydroimprovement.com/)

Check this out, I used his example to run on my PIC32 ESK.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 10, 2012, 10:05am UTC](https://forums.freertos.org/t/pic32-port-example/1909/13 "2012-02-10T10:05:42Z")

</div>

**[kn3chip](https://sourceforge.net/u/kn3chip/)** wrote on [Friday, February 10, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/531198e5/#6ca7):

freeRTOS v.7.1.0 along with&nbsp; c32 PIC32&nbsp; v2.02 with MPLAB IDE v8.83 works fine on my PIC32 Starter kit . The three LEDs re blinking using the LED task. I have used the PIC32MX\_MPLAB port and changed the LED port to PORTD since that port is used by starter kit for LEDs

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 20, 2012, 1:15am UTC](https://forums.freertos.org/t/pic32-port-example/1909/14 "2012-02-20T01:15:19Z")

</div>

**[kn3chip](https://sourceforge.net/u/kn3chip/)** wrote on [Monday, February 20, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/531198e5/#f59f):

Hi,  
One more update, when I tried to run the vAltStartComTestTasks() on&nbsp; PIC32MX795F512(chiKITMAX32board ) , the board was hanging(no blink of port D LED. I have modified the UART2 ISR to send a blank char ‘E’, in the QUE empty condition as below.  
With this change, the blink happens and the UART2 is sending characters. I have disabled the check tasks.  
There is&nbsp; a&nbsp; statement in microchip that interrupt would get generated "immediately’ when the UART is enabled. The output from UAR2&nbsp; is as given below the code snippet.

while( !( U2STAbits.UTXBF ) )  
{  
if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xHigherPriorityTaskWoken ) == pdTRUE )  
{  
// Send the next character queued for Tx.  
U2TXREG = cChar;  
// U2TXREG = ‘A’; // test code  
}  
else  
{  
// Queue empty, nothing to send.  
xTxHasEnded = pdTRUE;  
U2TXREG = ‘E’;&nbsp; //test code  
break;  
}  
}

EEEEEEEEEEABCDEFGHIJKLMNOPQRSTUVWXEEEEEEEEEEEEEEEEEEEEEEEEABCDEFGHIJKLMNOPQRSTUVWXEEEEEEEEEEEEEEEEEEEEEEEEEEEABCDEFGHIJKLMNOPQRSTUVWXEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEABCDEFGHIJKLMNOPQRSTUVWXEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEABCDEFGHIJKLMNOPQRSTUVWXEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

---

<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:** [February 20, 2012, 6:00am UTC](https://forums.freertos.org/t/pic32-port-example/1909/15 "2012-02-20T06:00:07Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Monday, February 20, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/531198e5/#3bde):

Note that, if you are using the UART driver from the Explorer16 demo, it is written for a PIC32MX360F512 and will not work correctly on the 795 part (because the UART and/or interrupt controller implementation is different).&nbsp; I can’t remember exactly what the changes needed are, but it has something to do with when the interrupt is cleared.&nbsp; Try clearing the interrupt as the first action in the ISR.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 21, 2012, 4:49pm UTC](https://forums.freertos.org/t/pic32-port-example/1909/16 "2012-09-21T16:49:41Z")

</div>

**[rwwall](https://sourceforge.net/u/rwwall/)** wrote on [Friday, September 21, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/531198e5/#d943):

I recently upgraded to MPLAB 8.86 and I also downloaded the August 2012 source code.&nbsp; The I now get the following warning:

Executing: “C:\Program Files\Microchip\MPLAB C32 Suite\bin\pic32-gcc.exe” -mprocessor=32MX795F512L -c -MMD -MF"./output\port\_asm.d" -I"." -I"." -I"…\common\include" -I"…\…\source\portable\mplab\pic32mx" -I"…\…\source\include" -D\_\_DEBUG -D\_\_MPLAB\_DEBUGGER\_PK3=1 “…\…\Source\portable\MPLAB\PIC32MX\port\_asm.S” -o"./output\port\_asm.o" -I"…\…\Source\portable\MPLAB\PIC32MX" -I"." -Wa,-defsym=\_\_DEBUG=1,-defsym=\_\_MPLAB\_DEBUGGER\_PK3=1,-keep-locals,-gdwarf-2  
…\…\Source\portable\MPLAB\PIC32MX\port\_asm.S: Assembler messages:  
…\…\Source\portable\MPLAB\PIC32MX\port\_asm.S:72: Warning: Quoted section flags are deprecated, use attributes instead

I don’t get this warning when using MPLAB 8.76.&nbsp; There&nbsp; is no information on the internet that I can find that describes how to use attributes to eliminate this warning concerning depreciated code

The line of code marked is: .section .FreeRTOS, “ax”, @progbits

---

<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:** [September 21, 2012, 6:02pm UTC](https://forums.freertos.org/t/pic32-port-example/1909/17 "2012-09-21T18:02:51Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Friday, September 21, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/531198e5/#0eb7):

> downloaded the August 2012 source code

I presume you mean the FreeRTOS source code.

The warnings are a result of changes made to the compiler.&nbsp; FreeRTOS was updated to work with the latest compiler.&nbsp; If you are using the latest FreeRTOS source code, and the latest XC32 compiler, then you should not get these warnings.

Regards.
