<?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: MK22 Floating Conversions Takes Really Long Time in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK22-Floating-Conversions-Takes-Really-Long-Time/m-p/855660#M51323</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the input Erich.&amp;nbsp; I tired using the f-suffix, but I'm getting about the same results as before.&amp;nbsp; Anyway, I've since changed the code so that I do the conversions after each ADC sample is ready and just populate the float buffer with that value -&amp;nbsp; no intermediate buffers/conversions.&amp;nbsp; With that, I have the main loop at about 400us (from 6ms).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Mar 2019 17:04:09 GMT</pubDate>
    <dc:creator>ec123</dc:creator>
    <dc:date>2019-03-14T17:04:09Z</dc:date>
    <item>
      <title>MK22 Floating Conversions Takes Really Long Time</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK22-Floating-Conversions-Takes-Really-Long-Time/m-p/855658#M51321</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My processor is running at 40MHz bus.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm working with an array of uint32_t and converting it to floats to another array.&amp;nbsp;&amp;nbsp;&amp;nbsp;The maximum size is 128 elements in each array.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I verified my application takes 6ms+ to loop and narrowed down the problem to the code below.&amp;nbsp; This code takes 6ms to run:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;STRONG style="color: #7f0055; font-size: small; "&gt;for&lt;/STRONG&gt;&lt;SPAN style="font-size: small;"&gt; ( i = 0; i &amp;lt; currentBufferSize &amp;amp;&amp;amp; i &amp;lt; nSamples; i++ )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; FsamplesA[i] = (&lt;/SPAN&gt;&lt;STRONG style=": ; color: #7f0055; font-size: small; "&gt;float&lt;/STRONG&gt;&lt;SPAN style="font-size: small;"&gt;)samplesA[i]*3.3/4096.0 - fZeroCurrent;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; FsamplesB[i] = (&lt;/SPAN&gt;&lt;STRONG style=": ; color: #7f0055; font-size: small; "&gt;float&lt;/STRONG&gt;&lt;SPAN style="font-size: small;"&gt;)samplesB[i]*3.3/4096.0 - fZeroCurrent;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; FsamplesC[i] = (&lt;/SPAN&gt;&lt;STRONG style=": ; color: #7f0055; font-size: small; "&gt;float&lt;/STRONG&gt;&lt;SPAN style="font-size: small;"&gt;)samplesC[i]*3.3/4096.0 - fZeroCurrent;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So there is an assignment after a&amp;nbsp;cast, multiplication, division and a simple offset subtraction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I&amp;nbsp;calculated it takes 624 instruction cycles to do the calcs and populate just a single&amp;nbsp;float buffer element!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does this seem right for a Cortex-M4F?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using MCUXpresso V10.2.0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Mar 2019 20:13:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK22-Floating-Conversions-Takes-Really-Long-Time/m-p/855658#M51321</guid>
      <dc:creator>ec123</dc:creator>
      <dc:date>2019-03-13T20:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: MK22 Floating Conversions Takes Really Long Time</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK22-Floating-Conversions-Takes-Really-Long-Time/m-p/855660#M51323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the input Erich.&amp;nbsp; I tired using the f-suffix, but I'm getting about the same results as before.&amp;nbsp; Anyway, I've since changed the code so that I do the conversions after each ADC sample is ready and just populate the float buffer with that value -&amp;nbsp; no intermediate buffers/conversions.&amp;nbsp; With that, I have the main loop at about 400us (from 6ms).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Mar 2019 17:04:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK22-Floating-Conversions-Takes-Really-Long-Time/m-p/855660#M51323</guid>
      <dc:creator>ec123</dc:creator>
      <dc:date>2019-03-14T17:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: MK22 Floating Conversions Takes Really Long Time</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK22-Floating-Conversions-Takes-Really-Long-Time/m-p/855661#M51324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ed,&lt;/P&gt;&lt;P&gt;see as well the discussion in &lt;A class="link-titled" href="https://mcuoneclipse.com/2019/03/29/be-aware-floating-point-operations-on-arm-cortex-m4f/" title="https://mcuoneclipse.com/2019/03/29/be-aware-floating-point-operations-on-arm-cortex-m4f/"&gt;Be aware: Floating Point Operations on ARM Cortex-M4F | MCU on Eclipse&lt;/A&gt;&amp;nbsp; on that subject. You can use a gcc compiler option to force single precision constants too.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 31 Mar 2019 08:13:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK22-Floating-Conversions-Takes-Really-Long-Time/m-p/855661#M51324</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2019-03-31T08:13:31Z</dc:date>
    </item>
  </channel>
</rss>

