<?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: [MQX on K64] post a semaphore during an interrupt creates a hardfault in Kinetis Software Development Kit</title>
    <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/MQX-on-K64-post-a-semaphore-during-an-interrupt-creates-a/m-p/426013#M2343</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your answer, I've looked at the link, but I am using the irq functions of the example, so it doesn't seem to be an issue. And I don't see how can I change it. They are defined this way :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// DMA (0 to 15)&lt;/P&gt;&lt;P&gt;void DMA0_IRQHandler(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; EDMA_DRV_IRQHandler(0);&lt;/P&gt;&lt;P&gt;} [...]&lt;/P&gt;&lt;P&gt;// SAI&lt;/P&gt;&lt;P&gt;void I2S0_Tx_IRQHandler(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SAI_DRV_TxIRQHandler(0U);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void I2S0_Rx_IRQHandler(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SAI_DRV_RxIRQHandler(0U);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If anyone has an idea, let me know !&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 Nov 2015 12:16:50 GMT</pubDate>
    <dc:creator>samuelboivineau</dc:creator>
    <dc:date>2015-11-24T12:16:50Z</dc:date>
    <item>
      <title>[MQX on K64] post a semaphore during an interrupt creates a hardfault</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/MQX-on-K64-post-a-semaphore-during-an-interrupt-creates-a/m-p/426011#M2341</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried to use most of the project sai_demo to test the SAI peripheral, but I have been stuck for a few days by a semaphore posted during an interrupt that creates a hardfault. The target is a K64F120M.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In fsl_soundcard.c, the function OSA_SemaPost(&amp;amp;buffer-&amp;gt;sem) is used by SND_TxCallback, called by SND_TxDmaCallback, that is called by a DMA interrupt if my understanding is correct :&lt;/P&gt;&lt;P&gt;- EDMA_DRV_InstallCallback(&amp;amp;ctrl-&amp;gt;dma_channel, SND_TxDmaCallback, (void *)card);&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the MQX documentation, I don't see anything about interrupt context.&lt;/P&gt;&lt;P&gt;And if I follow the post of the semaphore, then the sw goes to _lwsem_post, and sees that the semaphore is at 0, and a task is waiting for it, so the task is set ready and _CHECK_RUN_SCHEDULER is called. Then I jump into my HardFault_Handler, and I got those registers :&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;r0 = 0x1&lt;/P&gt;&lt;P&gt;r1 = 0x2000049c&lt;/P&gt;&lt;P&gt;r2 = 0x1&lt;/P&gt;&lt;P&gt;r3 = 0x1&lt;/P&gt;&lt;P&gt;r12 = 0x1fff0be0&lt;/P&gt;&lt;P&gt;lr = 0x30ab3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =&amp;gt; in the code of _lwsem_wait_ticks, after _sched_execute_scheduler_internal and the result.&lt;/P&gt;&lt;P&gt;pc = 0x4b6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =&amp;gt; instruction "bx lr"&amp;nbsp; in _sched_execute_scheduler_internal (defined by macro as _CHECK_RUN_SCHEDULER)&lt;/P&gt;&lt;P&gt;psr = 0x1000000&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So is it ok to post a semaphore inside an interrupt ?&lt;/P&gt;&lt;P&gt;Maybe I have a missed some configuration ?&lt;/P&gt;&lt;P&gt;Currently I am doing some polling but it's not the aim for a rtos ...&lt;/P&gt;&lt;P&gt;What is also curious is the link register with a value with 3 at the end, there is no alignement required ? It would be some register over-written by someone ? but who ? And which stack or heap would be impacted ?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Nov 2015 16:19:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/MQX-on-K64-post-a-semaphore-during-an-interrupt-creates-a/m-p/426011#M2341</guid>
      <dc:creator>samuelboivineau</dc:creator>
      <dc:date>2015-11-19T16:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: [MQX on K64] post a semaphore during an interrupt creates a hardfault</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/MQX-on-K64-post-a-semaphore-during-an-interrupt-creates-a/m-p/426012#M2342</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you have met the same doubt I have before&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this link page will help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/thread/379827"&gt;https://community.freescale.com/thread/379827&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Nov 2015 00:58:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/MQX-on-K64-post-a-semaphore-during-an-interrupt-creates-a/m-p/426012#M2342</guid>
      <dc:creator>keetle</dc:creator>
      <dc:date>2015-11-20T00:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: [MQX on K64] post a semaphore during an interrupt creates a hardfault</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/MQX-on-K64-post-a-semaphore-during-an-interrupt-creates-a/m-p/426013#M2343</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your answer, I've looked at the link, but I am using the irq functions of the example, so it doesn't seem to be an issue. And I don't see how can I change it. They are defined this way :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// DMA (0 to 15)&lt;/P&gt;&lt;P&gt;void DMA0_IRQHandler(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; EDMA_DRV_IRQHandler(0);&lt;/P&gt;&lt;P&gt;} [...]&lt;/P&gt;&lt;P&gt;// SAI&lt;/P&gt;&lt;P&gt;void I2S0_Tx_IRQHandler(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SAI_DRV_TxIRQHandler(0U);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void I2S0_Rx_IRQHandler(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SAI_DRV_RxIRQHandler(0U);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If anyone has an idea, let me know !&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Nov 2015 12:16:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/MQX-on-K64-post-a-semaphore-during-an-interrupt-creates-a/m-p/426013#M2343</guid>
      <dc:creator>samuelboivineau</dc:creator>
      <dc:date>2015-11-24T12:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: [MQX on K64] post a semaphore during an interrupt creates a hardfault</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/MQX-on-K64-post-a-semaphore-during-an-interrupt-creates-a/m-p/426014#M2344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It means that your interrup function name should not be same &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;as the CMSIS startup code file interrupt function name. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="capture201511251001251.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/51949iBA9F26FF5273F327/image-size/large?v=v2&amp;amp;px=999" role="button" title="capture201511251001251.png" alt="capture201511251001251.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so your function name "&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;DMA0_IRQHandler&lt;/SPAN&gt;" etc are illegal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can modify the illegal function name like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;void MQX_DMA0_IRQHandler(void)&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;{&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; EDMA_DRV_IRQHandler(0);&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;}&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;after that, register interrupt function&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;_int_install_isr(DMA0_IRQn, (INT_ISR_FPTR)&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;MQX_DMA0_IRQHandler&lt;/SPAN&gt;, NULL);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;after all,&amp;nbsp; it should be OK.:smileyhappy:&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2015 02:13:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/MQX-on-K64-post-a-semaphore-during-an-interrupt-creates-a/m-p/426014#M2344</guid>
      <dc:creator>keetle</dc:creator>
      <dc:date>2015-11-25T02:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: [MQX on K64] post a semaphore during an interrupt creates a hardfault</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/MQX-on-K64-post-a-semaphore-during-an-interrupt-creates-a/m-p/426015#M2345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your solution solved the issue. Thanks a lot !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2015 15:34:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/MQX-on-K64-post-a-semaphore-during-an-interrupt-creates-a/m-p/426015#M2345</guid>
      <dc:creator>samuelboivineau</dc:creator>
      <dc:date>2015-11-25T15:34:39Z</dc:date>
    </item>
  </channel>
</rss>

