<?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 - Protecting shared functions using lightweight semaphores in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-Protecting-shared-functions-using-lightweight-semaphores/m-p/484747#M15896</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi David,&lt;/P&gt;&lt;P&gt;Thank your for your prompt response, just wanted to check I wasn't missing something obvious.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mike &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 24 Feb 2016 16:43:51 GMT</pubDate>
    <dc:creator>mikemorris</dc:creator>
    <dc:date>2016-02-24T16:43:51Z</dc:date>
    <item>
      <title>MQX - Protecting shared functions using lightweight semaphores</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-Protecting-shared-functions-using-lightweight-semaphores/m-p/484745#M15894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 11.5pt; font-family: Helvetica, sans-serif;"&gt;Hi, &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.5pt; font-family: Helvetica, sans-serif;"&gt;I have a custom board (based on the twrk60n512) where I am using a number of tasks to perform various tasks. The application is configured to use priority based scheduling.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.5pt; font-family: Helvetica, sans-serif;"&gt;Two of the tasks in particular use the _io_write function to pass data to two individual uart channels,1 uart channel per task.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.5pt; font-family: Helvetica, sans-serif;"&gt;During testing I have found that the uart transmission (running at 115200 baud) from the lower priority task can have a delay of 15-20ms within the packet, this causes the field device (on customers side) to time out is it believes the transmission has ended. It is worth mentioning that no data is lost just an unexpected delay.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.5pt; font-family: Helvetica, sans-serif;"&gt;I believe that the lower priory task starts to transmit and is then blocked by the higher priory task which then also&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.5pt; font-family: Helvetica, sans-serif;"&gt;To get around this I am using a lightweight semaphore, I wait for the semaphore before the _io_write and post the semaphore immediately after the fflush function.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.5pt; font-family: Helvetica, sans-serif;"&gt;_lwsem_wait(&amp;amp;ModbusSem);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.5pt; font-family: Helvetica, sans-serif;"&gt;write(modbusslave, uc_MSOut, length);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.5pt; font-family: Helvetica, sans-serif;"&gt;fflush(modbusslave);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.5pt; font-family: Helvetica, sans-serif;"&gt;_lwsem_post(&amp;amp;ModbusSem);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.5pt; font-family: Helvetica, sans-serif;"&gt;This seems to resolve the problem.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.5pt; font-family: Helvetica, sans-serif;"&gt;The question I have is there anything additional I should consider when using semaphores? Im new to MQX and am looking for some general advice.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.5pt; font-family: Helvetica, sans-serif;"&gt;&lt;BR /&gt; Thanks in advance,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.5pt; font-family: Helvetica, sans-serif;"&gt;Mike&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Feb 2016 16:26:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-Protecting-shared-functions-using-lightweight-semaphores/m-p/484745#M15894</guid>
      <dc:creator>mikemorris</dc:creator>
      <dc:date>2016-02-24T16:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: MQX - Protecting shared functions using lightweight semaphores</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-Protecting-shared-functions-using-lightweight-semaphores/m-p/484746#M15895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mike,&lt;/P&gt;&lt;P&gt;That solution looks correct.&lt;/P&gt;&lt;P&gt;FYI the TWR-K60N512 is the original K60 silicon Rev 1.x which is very old.&amp;nbsp; The Rev 2.x silicon is on the TWR-K60D100M.&lt;/P&gt;&lt;P&gt;Lots of low level RTOS examples are at : C:\Freescale\Freescale_MQX_4_2\mqx\examples &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Specific example: C:\Freescale\Freescale_MQX_4_2\mqx\examples\lwsem &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;David &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Feb 2016 16:35:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-Protecting-shared-functions-using-lightweight-semaphores/m-p/484746#M15895</guid>
      <dc:creator>DavidS</dc:creator>
      <dc:date>2016-02-24T16:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: MQX - Protecting shared functions using lightweight semaphores</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-Protecting-shared-functions-using-lightweight-semaphores/m-p/484747#M15896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi David,&lt;/P&gt;&lt;P&gt;Thank your for your prompt response, just wanted to check I wasn't missing something obvious.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mike &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Feb 2016 16:43:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-Protecting-shared-functions-using-lightweight-semaphores/m-p/484747#M15896</guid>
      <dc:creator>mikemorris</dc:creator>
      <dc:date>2016-02-24T16:43:51Z</dc:date>
    </item>
  </channel>
</rss>

