<?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: Task Synchronization in Sensors</title>
    <link>https://community.nxp.com/t5/Sensors/Task-Synchronization/m-p/486431#M2878</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You just missed the synchronization functions.&amp;nbsp; Look at the top and bottom of the while(1) loop in RdSensData_task in mqx_tasks.c.&amp;nbsp; Near the top you will find:&lt;/P&gt;&lt;P style="text-align: center;"&gt;_lwevent_wait_for(&amp;amp;(Globals.&lt;SPAN style="color: #0000c0; font-size: 10pt;"&gt;SamplingEventStruct&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;), 1, FALSE, NULL); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;That event is set in FTM_OnCounterRestart() in Events.c.&amp;nbsp; That is, when the main loop counter indicates start of a new read sample.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Near the bottom you will find &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="color: #0000c0; font-size: 10pt;"&gt;_lwevent_set(&amp;amp;(globalsRunKFEventStruct&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;), 1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;which then triggers &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="color: #0000c0; font-size: 10pt;"&gt;_lwevent_wait_for(&amp;amp;globals.RunKFEventStruct&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;), 1, FALSE, NULL);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;inside Fusion_task().&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Apr 2016 15:50:30 GMT</pubDate>
    <dc:creator>michaelestanley</dc:creator>
    <dc:date>2016-04-28T15:50:30Z</dc:date>
    <item>
      <title>Task Synchronization</title>
      <link>https://community.nxp.com/t5/Sensors/Task-Synchronization/m-p/486430#M2877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In mqx_tasks.c, the global data structures such as "struct AccelSensor thisAccel and MagSensor thisMag" are shared resources between the high priority Sampling Task and the low priority Fusion Task, I do not see any synchronization object being used in the source code to protect those shared resources.&amp;nbsp; &lt;STRONG&gt;Is there a possibility for a race condition in the sensor fusion library?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Example: &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sampling Task updates &lt;STRONG&gt;fGsAvg[i]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;thisAccel.fGsAvg[i] = (float)thisAccel.iGsAvg[i] * thisAccel.fgPerCount;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Fusion Task accesses&lt;STRONG&gt; pthisAccel-&amp;gt;fGsAvg&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;eCompassNED(pthisSV-&amp;gt;fR, &amp;amp;(pthisSV-&amp;gt;fDelta), pthisMag-&amp;gt;fBcAvg, pthisAccel-&amp;gt;fGsAvg);&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="j-rte-table"&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style=""&gt;&lt;/TD&gt;&lt;TD style=""&gt;case NED:&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style=""&gt;&lt;/TD&gt;&lt;TD style=""&gt;&lt;/TD&gt;&lt;TD style=""&gt;feCompassNED(pthisSV-&amp;gt;fR, &amp;amp;(pthisSV-&amp;gt;fDelta), pthisMag-&amp;gt;fBcAvg, pthisAccel-&amp;gt;fGsAvg);&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style=""&gt;&lt;/TD&gt;&lt;TD style=""&gt;&lt;/TD&gt;&lt;TD style=""&gt;break;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style=""&gt;&lt;/TD&gt;&lt;TD style=""&gt;case ANDROID:&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style=""&gt;&lt;/TD&gt;&lt;TD style=""&gt;&lt;/TD&gt;&lt;TD style=""&gt;feCompassAndroid(pthisSV-&amp;gt;fR, &amp;amp;(pthisSV-&amp;gt;fDelta), pthisMag-&amp;gt;fBcAvg, pthisAccel-&amp;gt;fGsAvg);&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style=""&gt;&lt;/TD&gt;&lt;TD style=""&gt;&lt;/TD&gt;&lt;TD style=""&gt;break;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style=""&gt;&lt;/TD&gt;&lt;TD style=""&gt;case WIN8:&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style=""&gt;&lt;/TD&gt;&lt;TD style=""&gt;default:&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style=""&gt;&lt;/TD&gt;&lt;TD style=""&gt;&lt;/TD&gt;&lt;TD style=""&gt;feCompassWin8(pthisSV-&amp;gt;fR, &amp;amp;(pthisSV-&amp;gt;fDelta), pthisMag-&amp;gt;fBcAvg, pthisAccel-&amp;gt;fGsAvg);&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Apr 2016 09:25:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/Task-Synchronization/m-p/486430#M2877</guid>
      <dc:creator>huangnanjing</dc:creator>
      <dc:date>2016-04-28T09:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: Task Synchronization</title>
      <link>https://community.nxp.com/t5/Sensors/Task-Synchronization/m-p/486431#M2878</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You just missed the synchronization functions.&amp;nbsp; Look at the top and bottom of the while(1) loop in RdSensData_task in mqx_tasks.c.&amp;nbsp; Near the top you will find:&lt;/P&gt;&lt;P style="text-align: center;"&gt;_lwevent_wait_for(&amp;amp;(Globals.&lt;SPAN style="color: #0000c0; font-size: 10pt;"&gt;SamplingEventStruct&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;), 1, FALSE, NULL); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;That event is set in FTM_OnCounterRestart() in Events.c.&amp;nbsp; That is, when the main loop counter indicates start of a new read sample.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Near the bottom you will find &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="color: #0000c0; font-size: 10pt;"&gt;_lwevent_set(&amp;amp;(globalsRunKFEventStruct&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;), 1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;which then triggers &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="color: #0000c0; font-size: 10pt;"&gt;_lwevent_wait_for(&amp;amp;globals.RunKFEventStruct&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;), 1, FALSE, NULL);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;inside Fusion_task().&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Apr 2016 15:50:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/Task-Synchronization/m-p/486431#M2878</guid>
      <dc:creator>michaelestanley</dc:creator>
      <dc:date>2016-04-28T15:50:30Z</dc:date>
    </item>
  </channel>
</rss>

