# PIC32 StarterKit General Exception Handler cr

**URL:** <https://forums.freertos.org/t/pic32-starterkit-general-exception-handler-cr/1004>\
**Category:** Kernel\
**Created:** [June 10, 2011, 6:29am UTC](https://forums.freertos.org/t/pic32-starterkit-general-exception-handler-cr/1004 "2011-06-10T06:29:05Z")\
**Posts on this page:** 6\
**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:** [June 10, 2011, 6:29am UTC](https://forums.freertos.org/t/pic32-starterkit-general-exception-handler-cr/1004/1 "2011-06-10T06:29:05Z")

</div>

**[pistole89](https://sourceforge.net/u/pistole89/)** wrote on [Friday, June 10, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/2e5e0006/#f58d):

Hallo everyone,

I am using PIC32 Starter

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 10, 2011, 6:43am UTC](https://forums.freertos.org/t/pic32-starterkit-general-exception-handler-cr/1004/2 "2011-06-10T06:43:04Z")

</div>

**[pistole89](https://sourceforge.net/u/pistole89/)** wrote on [Friday, June 10, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/2e5e0006/#459e):

Hallo everyone,  
Sorry I make accidentally pressed enter.

I am using PIC32 Starter kit (PIC32MX360F512L). freeRTOSv5.10  
C32 Compiler v1.05  
MPLABv8.60

Previously, I have made it work to create task such as blinking LED.  
Then I port it with API from Microchip Graphics Library.  
There is no problem.

Next, I also implement FS API from Microchip with FreeRTOS.  
It crash and go to  
void \_general\_exception\_handler( unsigned portLONG ulCause, unsigned portLONG ulStatus )  
it crashed here and never back.

Then I add  
taskENTER\_CRITICAL();  
while(1)  
{  
}  
taskEXIT\_CRITICAL();

It worked, but the task will be always executed (looping here)  
It never go to applicationIdleHook.

So, I think that it is not the solution.

I suspicious that the problem is on Stack.  
I have modified configMINIMAL\_STACK\_SIZE, but nothing was changed.  
Even, the memory gauge on MPLAB did not changed the Data memory.

Does anyone have the solution ?  
Any suggestions would be very appreciated.

Thanks

---

<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:** [June 10, 2011, 7:16am UTC](https://forums.freertos.org/t/pic32-starterkit-general-exception-handler-cr/1004/3 "2011-06-10T07:16:39Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Friday, June 10, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/2e5e0006/#f2fc):

\> It worked, but the task will be always executed (looping here) It  
\> never go to applicationIdleHook.

You have locked it in a null loop in a critical section.&nbsp; It will not leave that code, and the tick interrupt is being held off by the critical section.&nbsp; I would expect that to be the only code that executed (except interrupts that are above a certain priority level that are not effected by the critical section).

\>  
\> So, I think that it is not the solution.  
\>  
\> I suspicious that the problem is on Stack. I have modified  
\> configMINIMAL\_STACK\_SIZE, but nothing was changed. Even, the memory  
\> gauge on MPLAB did not changed the Data memory.

You can turn stack checking on, if it is not on already.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 10, 2011, 11:40am UTC](https://forums.freertos.org/t/pic32-starterkit-general-exception-handler-cr/1004/4 "2011-06-10T11:40:19Z")

</div>

**[pistole89](https://sourceforge.net/u/pistole89/)** wrote on [Friday, June 10, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/2e5e0006/#7779):

Hi richard,

Thank you very much.

\>You can turn stack checking on, if it is not on already.  
Do you mean&nbsp; #define configCHECK\_FOR\_STACK\_OVERFLOW 2&nbsp;&nbsp; (in FreeRTOSConfig.h)&nbsp; ?  
I have turned it more than 0. (2)  
It never go to void vApplicationStackOverflowHook( void )  
Is this mean that there is no stack overflow ?

Before the program went to  
void \_general\_exception\_handler( unsigned portLONG ulCause, unsigned portLONG ulStatus )  
The program is break in port\_asm.S

portRESTORE\_CONTEXT

There is error below in MPLAB IDE  
CORE-E0002: Exception due to misaligned word access, from instruction at 0x9d01b28c

What does it mean ?

Thank you very much.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 10, 2011, 4:51pm UTC](https://forums.freertos.org/t/pic32-starterkit-general-exception-handler-cr/1004/5 "2011-06-10T16:51:30Z")

</div>

**[davedoors](https://sourceforge.net/u/davedoors/)** wrote on [Friday, June 10, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/2e5e0006/#4e9f):

Some architectures need word (32 bit) data and instructions to be aligned on 32 bit boundaries in memory. And if you try reading, writing, or executing a 32 variable or instruction that is not on a 32 bit boundary you will get a misaligned word access exception.

It tells you the address of the instruction that caused the exception, so you need to look up what is at that address.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 11, 2011, 11:37am UTC](https://forums.freertos.org/t/pic32-starterkit-general-exception-handler-cr/1004/6 "2011-06-11T11:37:36Z")

</div>

**[pistole89](https://sourceforge.net/u/pistole89/)** wrote on [Saturday, June 11, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/2e5e0006/#e4a3):

Hi dave,

Thanks for your suggestion.

If I know the address of instruction which caused the exception, how to know what kind of instruction in C ?  
MPLAB will generate the .hex , but I do not know which instruction in C.

Thank you very much…&nbsp;&nbsp;
