# Hangs on PIC32 uxPortSetInterruptMaskFromISR

**URL:** <https://forums.freertos.org/t/hangs-on-pic32-uxportsetinterruptmaskfromisr/227>\
**Category:** Kernel\
**Created:** [July 22, 2013, 6:31am UTC](https://forums.freertos.org/t/hangs-on-pic32-uxportsetinterruptmaskfromisr/227 "2013-07-22T06:31:31Z")\
**Posts on this page:** 3\
**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:** [July 22, 2013, 6:31am UTC](https://forums.freertos.org/t/hangs-on-pic32-uxportsetinterruptmaskfromisr/227/1 "2013-07-22T06:31:31Z")

</div>

**[l4na](https://sourceforge.net/u/l4na/)** wrote on [Monday, July 22, 2013](https://sourceforge.net/p/freertos/discussion/382005/thread/0b2fddb7/#ebe1):

Hi, I just started using FreeRTOS ( PIC32 ) and got an issue once I call xSemaphoreGiveFromISR. I call this API from an interrupt that is set to priority 1. I narrow down the hang to the uxPortSetInterruptMaskFromISR, when it tries to \_CP0\_SET\_STATUS. Couple of questions :  
1. uxSavedStatusRegister = \_CP0\_GET\_STATUS() | 0x01;  
Is this call really needed?&nbsp; when the interrupt happens, the IE bit should already set unless it is disable by the “asm volatile (“di”)” ? Any idea what might cause the hang? What puzzling is the Timer tick interrupt is also running with priority 1 and it has no issue.

2. portALL\_IPL\_BITS is set to 0x3fUL. From what I read in PIC32 spec, the IPL bits are bit 10-12 (3bits), shouldn’t this value be 0x7UL ?

Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 22, 2013, 7:49am UTC](https://forums.freertos.org/t/hangs-on-pic32-uxportsetinterruptmaskfromisr/227/2 "2013-07-22T07:49:47Z")

</div>

**[l4na](https://sourceforge.net/u/l4na/)** wrote on [Monday, July 22, 2013](https://sourceforge.net/p/freertos/discussion/382005/thread/0b2fddb7/#d25f):

Some update on issue 1, I found out the hang is caused by the interrupt bit is not yet cleared when I call that function.&nbsp; So as long as I clear the interrupt bit before calling the uxPortSetInterruptMaskFromISR , everything works fine.

---

<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 22, 2013, 10:55am UTC](https://forums.freertos.org/t/hangs-on-pic32-uxportsetinterruptmaskfromisr/227/3 "2013-07-22T10:55:59Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Monday, July 22, 2013](https://sourceforge.net/p/freertos/discussion/382005/thread/0b2fddb7/#c9fd):

Are you following the instructions in the “Interrupt Service Routines” section of the following page: [http://www.freertos.org/port\_PIC32\_MIPS\_MK4.html](http://www.freertos.org/port_PIC32_MIPS_MK4.html) ?&nbsp; You should never find interrupts are disabled inside the interrupt handler unless you disabled them.

Regards.
