# xxxxFromISR functions causing assert

**URL:** <https://forums.freertos.org/t/xxxxfromisr-functions-causing-assert/5869>\
**Category:** Kernel\
**Created:** [March 21, 2016, 10:06pm UTC](https://forums.freertos.org/t/xxxxfromisr-functions-causing-assert/5869 "2016-03-21T22:06:44Z")\
**Posts on this page:** 4\
**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:** [March 21, 2016, 10:06pm UTC](https://forums.freertos.org/t/xxxxfromisr-functions-causing-assert/5869/1 "2016-03-21T22:06:44Z")

</div>

**[sfmarks](https://sourceforge.net/u/sfmarks/)** wrote on [Monday, March 21, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/2dc08a4a/#2c1f):

Hello.  
I am writing a function, which is called both from task as well as from an isr.  
My FreeRTOS Version is 8.2.0.

```auto
xHigherPriorityTaskWoken == pdFALSE;

if(TRUE == Task)
{
    xQueueSendToBack(SendQueue,(uint32_t*) &send_a_Struct, 0);
 }
 else
 {
    Ticks = xTaskGetTickCountFromISR();
     xQueueSendToBackFromISR(SendQueue, (uint32_t*) &send_a_Struct, &xHigherPriorityTaskWoken)
  }

```

If I call the xTaskGetTickCountFromISR(); function, then the µController jumps to the vAssertCalled() function.  
If I comment the line with xTaskGetTickCountFromISR(), the µC jumps to vAssertCalled(), when calling the xQueueSendToBackFromISR() function.  
The callstack shows me, that the µC jumps to  
vPortValidateInterruptPriority() and call the macro: configASSERT( ucCurrentPriority \>= ucMaxSysCallPriority );  
configMAX\_SYSCALL\_INTERRUPT\_PRIORITY has the default value of 191.  
define configMAX\_SYSCALL\_INTERRUPT\_PRIORITY 191.  
I also experimented with other values but if the configMAX\_SYSCALL\_INTERRUPT\_PRIORITY value is smaller than 16 (15 is my lowest ISR priority) then the HardFault Handler is called.  
When the HardFault happen, the call stack shows me this:  
xPortStartScheduler  
prvPortStartFirstTask  
  
hardfaulthandler  
The hardfaulthandler is called because xQueueSendToBackFromISR is called.  
If i comment this line where xQueueSendToBackFromISR will be called, and the configMAX\_SYSCALL\_INTERRUPT\_PRIORITY stays at value of 15, then no hardfault happen.

I hope someone can help me.

Best Regards

---

<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:** [March 22, 2016, 9:22am UTC](https://forums.freertos.org/t/xxxxfromisr-functions-causing-assert/5869/2 "2016-03-22T09:22:42Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Tuesday, March 22, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/2dc08a4a/#6113):

> If I call the xTaskGetTickCountFromISR(); function, then the µController jumps to the vAssertCalled() function.

I have just looked at the xTaskGetTickCountFrom() function and the only assert I see is this one:

```auto
/* RTOS ports that support interrupt nesting have the concept of a maximum
system call (or maximum API call) interrupt priority. Interrupts that are
above the maximum system call priority are kept permanently enabled, even
when the RTOS kernel is in a critical section, but cannot make any calls to
FreeRTOS API functions. If configASSERT() is defined in FreeRTOSConfig.h
then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion
failure if a FreeRTOS API function is called from an interrupt that has been
assigned a priority above the configured maximum system call priority.
Only FreeRTOS functions that end in FromISR can be called from interrupts
that have been assigned a priority at or (logically) below the maximum
system call	interrupt priority. FreeRTOS maintains a separate interrupt
safe API to ensure interrupt entry is as fast and as simple as possible.
More information (albeit Cortex-M specific) is provided on the following
link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();

```

I’m not sure I can really add much more than the information provided in the comment at the assert point, or the more detailed information on the link provided in the comment. The obvious question then is, not have you tinkered with the configMAX\_SYSCALL\_INTERRUPT\_PRIORITY setting, but have you set the priority of the interrupt? Please read the link.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 22, 2016, 9:17pm UTC](https://forums.freertos.org/t/xxxxfromisr-functions-causing-assert/5869/3 "2016-03-22T21:17:34Z")

</div>

**[sfmarks](https://sourceforge.net/u/sfmarks/)** wrote on [Tuesday, March 22, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/2dc08a4a/#9f78):

Hello.  
Thank you for your answer.  
I found the bug.  
The explanation is:  
I activated the configAssert macro in freeRTOS.  
After this I got a failure while colling the xFromISR functions.  
The problem was, that the configMAX\_SYSCALL\_INTERRUPT\_PRIORITY was at the default value of 191. I changed the value from 191 to 15, while I worte my post yesterday (I overseen this define before).  
After I changed the value to 15 xTaskGetTickCountFrom didn’t cause any failure.  
But xQueueSendToBackFromISR crashes, as I wrote.  
While I was debug my assert failure, I tried to send an other struct.  
I removed this other struct and tried to send my origin struct, but I forgot to remove the other struct to my origin struct in the function call of xQueueSendToBackFromISR.  
So I set my origin struct and now the calling of xQueueSendToBackFromISR works.

Can you explain me, why configMAX\_SYSCALL\_INTERRUPT\_PRIORITY has the value of 191.  
I don’t understand this.

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:** [March 23, 2016, 8:49am UTC](https://forums.freertos.org/t/xxxxfromisr-functions-causing-assert/5869/4 "2016-03-23T08:49:04Z")

</div>

**[davedoors](https://sourceforge.net/u/davedoors/)** wrote on [Wednesday, March 23, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/2dc08a4a/#a96b):

did you read the link in the code comments in the last post?
