<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: FreeRTOS : xQueueSendFromISR in i.MX RT Crossover MCUs</title>
    <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/FreeRTOS-xQueueSendFromISR/m-p/1049931#M8008</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Most likely, you have not set the priority of that particular interrupt vector in the NVIC peripheral.&amp;nbsp; By default, all interrupt sources have a priority of 0 (which is the highest priority).&amp;nbsp; However, FreeRTOS needs to reserve at least the top-most interrupt priority for itself.&amp;nbsp; In FreeRTOSConfig.h, you'll find this line:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="property macro token"&gt;#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 2‍&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This defines the highest allowable priority for any interrupt that needs to call FreeRTOS functions, like your ISR does.&amp;nbsp; So in this example, the available priorities for your ISR would be 2, 3, 4... 15, 16.&amp;nbsp; You can have interrupts that are of higher priority (e.g. 0 or 1), but they &lt;SPAN style="text-decoration: underline;"&gt;must not call FreeRTOS API functions&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you're not setting the interrupt priority, then the priority is 0 by default, and when you call xQueueSendFromISR(), the assert fails because your ISR has the same or higher priority as the RTOS.&amp;nbsp; You fix this by calling:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="token function"&gt;NVIC_SetPriority&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;irqn&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; priority&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;where irqn is the identifier for your interrupt vector (e.g.&amp;nbsp;GPIO1_INT0_IRQn) and priority is your interrupt priority, which &lt;SPAN style="text-decoration: underline;"&gt;numerically&lt;/SPAN&gt; must be equal to or greater than&amp;nbsp;configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY.&amp;nbsp; Do this prior to enabling your interrupt.&amp;nbsp; For instance, if I want to set the interrupt priority for LPUART2 to 4, I would write&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="token function"&gt;NVIC_SetPriority&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;LPUART2_IRQn&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;4&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Try that, I suspect that will fix your problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;David R.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 20 Apr 2020 23:56:50 GMT</pubDate>
    <dc:creator>dmarks_ls</dc:creator>
    <dc:date>2020-04-20T23:56:50Z</dc:date>
    <item>
      <title>FreeRTOS : xQueueSendFromISR</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/FreeRTOS-xQueueSendFromISR/m-p/1049930#M8007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to message from ISR to Task.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, My code is are below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I use i.MX RT1064&lt;/P&gt;&lt;P&gt;void IsrKeyEvent(char event, char data) {&lt;/P&gt;&lt;P&gt;/* We have not woken a task at the start of the ISR. */&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; BaseType_t xHigherPriorityTaskWoken = pdFALSE;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; ISR_EVENT isrEvent;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; isrEvent.event = event;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; isrEvent.data = data;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; xQueueSendFromISR( xQueueIsr, &amp;amp;isrEvent, &amp;amp;xHigherPriorityTaskWoken );&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but&amp;nbsp;always assert fail in&amp;nbsp;vPortValidateInterruptPriority()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What's wrong ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 19 Apr 2020 00:22:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/FreeRTOS-xQueueSendFromISR/m-p/1049930#M8007</guid>
      <dc:creator>emvlabs</dc:creator>
      <dc:date>2020-04-19T00:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: FreeRTOS : xQueueSendFromISR</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/FreeRTOS-xQueueSendFromISR/m-p/1049931#M8008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Most likely, you have not set the priority of that particular interrupt vector in the NVIC peripheral.&amp;nbsp; By default, all interrupt sources have a priority of 0 (which is the highest priority).&amp;nbsp; However, FreeRTOS needs to reserve at least the top-most interrupt priority for itself.&amp;nbsp; In FreeRTOSConfig.h, you'll find this line:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="property macro token"&gt;#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 2‍&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This defines the highest allowable priority for any interrupt that needs to call FreeRTOS functions, like your ISR does.&amp;nbsp; So in this example, the available priorities for your ISR would be 2, 3, 4... 15, 16.&amp;nbsp; You can have interrupts that are of higher priority (e.g. 0 or 1), but they &lt;SPAN style="text-decoration: underline;"&gt;must not call FreeRTOS API functions&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you're not setting the interrupt priority, then the priority is 0 by default, and when you call xQueueSendFromISR(), the assert fails because your ISR has the same or higher priority as the RTOS.&amp;nbsp; You fix this by calling:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="token function"&gt;NVIC_SetPriority&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;irqn&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; priority&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;where irqn is the identifier for your interrupt vector (e.g.&amp;nbsp;GPIO1_INT0_IRQn) and priority is your interrupt priority, which &lt;SPAN style="text-decoration: underline;"&gt;numerically&lt;/SPAN&gt; must be equal to or greater than&amp;nbsp;configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY.&amp;nbsp; Do this prior to enabling your interrupt.&amp;nbsp; For instance, if I want to set the interrupt priority for LPUART2 to 4, I would write&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="token function"&gt;NVIC_SetPriority&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;LPUART2_IRQn&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;4&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Try that, I suspect that will fix your problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;David R.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Apr 2020 23:56:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/FreeRTOS-xQueueSendFromISR/m-p/1049931#M8008</guid>
      <dc:creator>dmarks_ls</dc:creator>
      <dc:date>2020-04-20T23:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: FreeRTOS : xQueueSendFromISR</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/FreeRTOS-xQueueSendFromISR/m-p/1049932#M8009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Also, once you get your interrupt working, you'll want to add this line to the end of your ISR:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="token function"&gt;taskYIELD_FROM_ISR&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;xHigherPriorityTaskWoken&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You can read here for more information as to why this is required.&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://stackoverflow.com/questions/58631246/freertos-why-to-call-taskyield-from-isr-method-within-the-isrhandler" rel="nofollow noopener noreferrer" title="https://stackoverflow.com/questions/58631246/freertos-why-to-call-taskyield-from-isr-method-within-the-isrhandler" target="_blank"&gt;rtos - FreeRTOS: Why to call taskYIELD_FROM_ISR() method within the isrHandler - Stack Overflow&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2020 00:02:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/FreeRTOS-xQueueSendFromISR/m-p/1049932#M8009</guid>
      <dc:creator>dmarks_ls</dc:creator>
      <dc:date>2020-04-21T00:02:02Z</dc:date>
    </item>
  </channel>
</rss>

