<?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 Calculating Sin/Cos with GFLIB in MCUXpresso IDE</title>
    <link>https://community.nxp.com/t5/MCUXpresso-IDE/Calculating-Sin-Cos-with-GFLIB/m-p/722321#M1155</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to write some simple code making use of GFLIB for an ARM Cortex M4F MCU. I have successfully included the library files, and have some code making use of the&amp;nbsp;GFLIB_Sin_FLT_C function from gflib_FP.h:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the below code, I am trying to build a sine-wave array (and phase-shifted copies) and store them in current_U, current_V, and current_W.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;int main(void) {&lt;BR /&gt;float current_U[36];&lt;BR /&gt; float current_V[36];&lt;BR /&gt; float current_W[36];&lt;BR /&gt; int i;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;for(i=0; i&amp;lt;NUM_PTS; i++) {&lt;BR /&gt; current_U[i] = GFLIB_Sin_FLT_C(i*10*PI/180.0); // input argument in radians&lt;BR /&gt; current_V[i] = GFLIB_Sin_FLT_C(i*10*PI/180.0 + 2*PI/3); // phase shift by +120deg&lt;BR /&gt; current_W[i] = GFLIB_Sin_FLT_C(i*10*PI/180.0 - 2*PI/3);&amp;nbsp;// phase shift by -120deg&amp;nbsp;&amp;nbsp;&lt;BR /&gt; }&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;}&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Strangely, the current_V calculation gives erroneous results:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/248i16F20BCE855A3CDB/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_2.png" alt="pastedImage_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why would this be? Since GFLIB is a pre-compiled library, I can't examine the code that is calculating the sine value. Why would the calculation only fail for one of the function calls?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 22 Mar 2018 00:53:31 GMT</pubDate>
    <dc:creator>aberger</dc:creator>
    <dc:date>2018-03-22T00:53:31Z</dc:date>
    <item>
      <title>Calculating Sin/Cos with GFLIB</title>
      <link>https://community.nxp.com/t5/MCUXpresso-IDE/Calculating-Sin-Cos-with-GFLIB/m-p/722321#M1155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to write some simple code making use of GFLIB for an ARM Cortex M4F MCU. I have successfully included the library files, and have some code making use of the&amp;nbsp;GFLIB_Sin_FLT_C function from gflib_FP.h:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the below code, I am trying to build a sine-wave array (and phase-shifted copies) and store them in current_U, current_V, and current_W.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;int main(void) {&lt;BR /&gt;float current_U[36];&lt;BR /&gt; float current_V[36];&lt;BR /&gt; float current_W[36];&lt;BR /&gt; int i;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;for(i=0; i&amp;lt;NUM_PTS; i++) {&lt;BR /&gt; current_U[i] = GFLIB_Sin_FLT_C(i*10*PI/180.0); // input argument in radians&lt;BR /&gt; current_V[i] = GFLIB_Sin_FLT_C(i*10*PI/180.0 + 2*PI/3); // phase shift by +120deg&lt;BR /&gt; current_W[i] = GFLIB_Sin_FLT_C(i*10*PI/180.0 - 2*PI/3);&amp;nbsp;// phase shift by -120deg&amp;nbsp;&amp;nbsp;&lt;BR /&gt; }&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;}&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Strangely, the current_V calculation gives erroneous results:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/248i16F20BCE855A3CDB/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_2.png" alt="pastedImage_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why would this be? Since GFLIB is a pre-compiled library, I can't examine the code that is calculating the sine value. Why would the calculation only fail for one of the function calls?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Mar 2018 00:53:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-IDE/Calculating-Sin-Cos-with-GFLIB/m-p/722321#M1155</guid>
      <dc:creator>aberger</dc:creator>
      <dc:date>2018-03-22T00:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Sin/Cos with GFLIB</title>
      <link>https://community.nxp.com/t5/MCUXpresso-IDE/Calculating-Sin-Cos-with-GFLIB/m-p/722322#M1156</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andy,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you tell us which MCU are you using?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;BR /&gt;Carlos Mendoza&lt;BR /&gt;Technical Support Engineer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Mar 2018 16:27:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-IDE/Calculating-Sin-Cos-with-GFLIB/m-p/722322#M1156</guid>
      <dc:creator>Carlos_Mendoza</dc:creator>
      <dc:date>2018-03-22T16:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Sin/Cos with GFLIB</title>
      <link>https://community.nxp.com/t5/MCUXpresso-IDE/Calculating-Sin-Cos-with-GFLIB/m-p/722323#M1157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using&amp;nbsp;the MK64FN1M0VMD12 (as a part of the TWR-K64F-120M dev board), and am working in MCUXpresso v10.1.0 build 589.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Mar 2018 16:33:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-IDE/Calculating-Sin-Cos-with-GFLIB/m-p/722323#M1157</guid>
      <dc:creator>aberger</dc:creator>
      <dc:date>2018-03-22T16:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Sin/Cos with GFLIB</title>
      <link>https://community.nxp.com/t5/MCUXpresso-IDE/Calculating-Sin-Cos-with-GFLIB/m-p/722324#M1158</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Problem solved:&lt;/P&gt;&lt;P&gt;The&amp;nbsp;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;GFLIB_Sin_FLT_C and Cos functions require the input argument in the range of -pi to +pi. I was inputting values &amp;gt;+pi.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;See:&amp;nbsp;&lt;A class="link-titled" href="https://www.nxp.com/docs/en/user-guide/CM4FGFLIBUG.pdf" title="https://www.nxp.com/docs/en/user-guide/CM4FGFLIBUG.pdf"&gt;https://www.nxp.com/docs/en/user-guide/CM4FGFLIBUG.pdf&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;Discussion of GFLIB_Sin algorithm on pg 35&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Mar 2018 21:15:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-IDE/Calculating-Sin-Cos-with-GFLIB/m-p/722324#M1158</guid>
      <dc:creator>aberger</dc:creator>
      <dc:date>2018-03-22T21:15:19Z</dc:date>
    </item>
  </channel>
</rss>

