# PIC32MZ SemaphoreGiveFromISR() causes exception

**URL:** <https://forums.freertos.org/t/pic32mz-semaphoregivefromisr-causes-exception/3723>\
**Category:** Kernel\
**Created:** [June 5, 2014, 2:44am UTC](https://forums.freertos.org/t/pic32mz-semaphoregivefromisr-causes-exception/3723 "2014-06-05T02:44:26Z")\
**Posts on this page:** 8\
**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 5, 2014, 2:44am UTC](https://forums.freertos.org/t/pic32mz-semaphoregivefromisr-causes-exception/3723/1 "2014-06-05T02:44:26Z")

</div>

**[pbjork](https://sourceforge.net/u/pbjork/)** wrote on [Thursday, June 05, 2014](https://sourceforge.net/p/freertos/discussion/382005/thread/a55c744b/#2711):

PIC32MZ2048ECH100, FreeRTOS0.8b, MPLABX 2.05, XC32 compiler v1.31.

Exceptions occur after several thousand successful ISR cycles exclusively in uxListRemove(), called from xTaskRemoveFromEventList() (which is several call levels down from SemaphoreGiveFromISR()). Either general or TLB exceptions may result. The pxEventList-\>uxNumberOfItems seems to be corrupted (or becomes very large), resulting in a null pxItemToRemove-\>pvContainer passed to uxListRemove(), which causes the exception.

I try to read the number of items to see if it is growing slowly, or just suddenly explodes, but it seems to go from typically 1 to a very large number suddenly.

Any ideas?

---

<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:** [June 5, 2014, 3:07am UTC](https://forums.freertos.org/t/pic32mz-semaphoregivefromisr-causes-exception/3723/2 "2014-06-05T03:07:47Z")

</div>

**[tlafleur](https://sourceforge.net/u/tlafleur/)** wrote on [Thursday, June 05, 2014](https://sourceforge.net/p/freertos/discussion/382005/thread/a55c744b/#2711/7791):

Just a note. I’m not using. xTaskRemoveFromEventList

---

<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:** [June 5, 2014, 3:16am UTC](https://forums.freertos.org/t/pic32mz-semaphoregivefromisr-causes-exception/3723/3 "2014-06-05T03:16:09Z")

</div>

**[tlafleur](https://sourceforge.net/u/tlafleur/)** wrote on [Thursday, June 05, 2014](https://sourceforge.net/p/freertos/discussion/382005/thread/a55c744b/#2711/eaf2):

I’m using the same processor with 8.0 Xc1.31, mplab 2.10 have not had an issue with that function.

Pic32mz2048ech. Rev a3

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 5, 2014, 4:45am UTC](https://forums.freertos.org/t/pic32mz-semaphoregivefromisr-causes-exception/3723/4 "2014-06-05T04:45:33Z")

</div>

**[pbjork](https://sourceforge.net/u/pbjork/)** wrote on [Thursday, June 05, 2014](https://sourceforge.net/p/freertos/discussion/382005/thread/a55c744b/#2711/7791/623d):

If you’re using SemaphoreGiveFromISR then that will eventually call xTaskRemoveFromEventList.

Yes, RevA3 on the processor.

BTW, this code was working on a PIC32MX part before I ported it to PIC32MZ.

---

<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 5, 2014, 5:21am UTC](https://forums.freertos.org/t/pic32mz-semaphoregivefromisr-causes-exception/3723/5 "2014-06-05T05:21:43Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Thursday, June 05, 2014](https://sourceforge.net/p/freertos/discussion/382005/thread/a55c744b/#8909):

Are you 100% sure the interrupt that is calling xSemaphoreGiveFromISR() has a priority at or below the priority set by configMAX\_SYSCALL\_INTERRUPT\_PRIORITY? Do you have configASSERT() defined? If so then that should trap an incorrect interrupt priority provided you are using a recent version of FreeRTOS (you say you are using FreeRTOS 0.8b, I don’t know what that is).

Regards,  
Richard Barry.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 5, 2014, 11:26am UTC](https://forums.freertos.org/t/pic32mz-semaphoregivefromisr-causes-exception/3723/6 "2014-06-05T11:26:00Z")

</div>

**[pbjork](https://sourceforge.net/u/pbjork/)** wrote on [Thursday, June 05, 2014](https://sourceforge.net/p/freertos/discussion/382005/thread/a55c744b/#76cf):

Oh, sorry, it’s FreeRTOS version 8.0.0 that was supplied with Microchip’s Harmony 0.8b framework.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 5, 2014, 11:29am UTC](https://forums.freertos.org/t/pic32mz-semaphoregivefromisr-causes-exception/3723/7 "2014-06-05T11:29:19Z")

</div>

**[pbjork](https://sourceforge.net/u/pbjork/)** wrote on [Thursday, June 05, 2014](https://sourceforge.net/p/freertos/discussion/382005/thread/a55c744b/#8909/b001):

Oh, sorry, it’s FreeRTOS version 8.0.0 that was supplied with Microchip’s Harmony 0.8b framework.

Ouch. For some kind of test I reset configMAX\_SYSCALL\_INTERRUPT\_PRIORITY from 6 down to 3, then forgot to move it back, I have several interrupts up to level 6. I’ll change it back and test.

I’ll also look into configASSERT(). I haven’t used it yet. Thank you Richard, for your prompt reply.

Paul

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 5, 2014, 11:40am UTC](https://forums.freertos.org/t/pic32mz-semaphoregivefromisr-causes-exception/3723/8 "2014-06-05T11:40:48Z")

</div>

**[pbjork](https://sourceforge.net/u/pbjork/)** wrote on [Thursday, June 05, 2014](https://sourceforge.net/p/freertos/discussion/382005/thread/a55c744b/#8909/b001/5523):

So far so good. Problem appears to have gone away, at least over a test length about 10 times as long as what it took the exception to be thrown before.

Good call.
