<?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>Kinetis MicrocontrollersのトピックHow to enable FPU in MK22FX512AVLQ12</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-enable-FPU-in-MK22FX512AVLQ12/m-p/1197074#M59094</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am using MK22FX512AVLQ12 microcontroller in my custom board design. I want to do some operations such as pow(), multiplication, division which involve uint64_t as well as float operands using FPU of Cortex M4 of controller. The Macro __FPU_PRESENT is 1 in MK22FA12.h file. Also I have defined&amp;nbsp; __FPU_PRESENT in project settings. But Macro&amp;nbsp; __FPU_USED is 0 in core_cm4.h by the conditions defined there.&lt;/P&gt;&lt;P&gt;After referring to &lt;A href="https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/10-useful-tips-to-using-the-floating-point-unit-on-the-arm-cortex--m4-processor" target="_blank" rel="noopener"&gt;link&lt;/A&gt;&amp;nbsp;I have enabled all the settings for HardABI in project settings. But after viewing the disassembly code , I find it is still using some of the software library functions.&lt;/P&gt;&lt;P&gt;For eg.&lt;/P&gt;&lt;P&gt;float&amp;nbsp; l_f_DifferenceCurr;&lt;/P&gt;&lt;P&gt;uint64_t l_ui64_DiffMultiplier = 0U;&lt;/P&gt;&lt;P&gt;&amp;nbsp;l_ui64_DiffMultiplier = (uint64_t)(l_f_DifferenceCurr * (float)MF_ONE_LAKH);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Please refer the attached screenshot of disassembly for Above line&lt;/P&gt;&lt;P&gt;I have included arm_math.h file and math.h file in the code.&lt;/P&gt;&lt;P&gt;Please suggest the appropriate steps to use FPU for float operations.&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Vaibhavi&lt;/P&gt;</description>
    <pubDate>Thu, 10 Dec 2020 04:42:20 GMT</pubDate>
    <dc:creator>vaibhavi_padwal</dc:creator>
    <dc:date>2020-12-10T04:42:20Z</dc:date>
    <item>
      <title>How to enable FPU in MK22FX512AVLQ12</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-enable-FPU-in-MK22FX512AVLQ12/m-p/1197074#M59094</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am using MK22FX512AVLQ12 microcontroller in my custom board design. I want to do some operations such as pow(), multiplication, division which involve uint64_t as well as float operands using FPU of Cortex M4 of controller. The Macro __FPU_PRESENT is 1 in MK22FA12.h file. Also I have defined&amp;nbsp; __FPU_PRESENT in project settings. But Macro&amp;nbsp; __FPU_USED is 0 in core_cm4.h by the conditions defined there.&lt;/P&gt;&lt;P&gt;After referring to &lt;A href="https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/10-useful-tips-to-using-the-floating-point-unit-on-the-arm-cortex--m4-processor" target="_blank" rel="noopener"&gt;link&lt;/A&gt;&amp;nbsp;I have enabled all the settings for HardABI in project settings. But after viewing the disassembly code , I find it is still using some of the software library functions.&lt;/P&gt;&lt;P&gt;For eg.&lt;/P&gt;&lt;P&gt;float&amp;nbsp; l_f_DifferenceCurr;&lt;/P&gt;&lt;P&gt;uint64_t l_ui64_DiffMultiplier = 0U;&lt;/P&gt;&lt;P&gt;&amp;nbsp;l_ui64_DiffMultiplier = (uint64_t)(l_f_DifferenceCurr * (float)MF_ONE_LAKH);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Please refer the attached screenshot of disassembly for Above line&lt;/P&gt;&lt;P&gt;I have included arm_math.h file and math.h file in the code.&lt;/P&gt;&lt;P&gt;Please suggest the appropriate steps to use FPU for float operations.&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Vaibhavi&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2020 04:42:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-enable-FPU-in-MK22FX512AVLQ12/m-p/1197074#M59094</guid>
      <dc:creator>vaibhavi_padwal</dc:creator>
      <dc:date>2020-12-10T04:42:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to enable FPU in MK22FX512AVLQ12</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-enable-FPU-in-MK22FX512AVLQ12/m-p/1197203#M59097</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/84017"&gt;@vaibhavi_padwal&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;this is a float to unsigned 64bit integral conversion. Your FPU is able to do single precision operations (add, sub, mul, ...) and float to intergral 32bit conversion. Because you want to use a 64bit integral, a software conversion has to be used.&lt;/P&gt;&lt;P&gt;So the question is: do you really need 64bit? Then yes, this is what you get.&lt;/P&gt;&lt;P&gt;If you are ok with 32bits, then you can use&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;l_ui64_DiffMultiplier = (uint32_t)(l_f_DifferenceCurr * (float)MF_ONE_LAKH);&lt;/LI-CODE&gt;&lt;P&gt;and you get something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; 10:	4b0a      	ldr	r3, [pc, #40]	; (3c &amp;lt;main+0x3c&amp;gt;)
  12:	edd3 7a00 	vldr	s15, [r3]
  16:	eeb0 7a08 	vmov.f32	s14, #8	; 0x40400000  3.0
  1a:	ee67 7a87 	vmul.f32	s15, s15, s14
  1e:	eefc 7ae7 	vcvt.u32.f32	s15, s15
  22:	ee17 3a90 	vmov	r3, s15
  26:	461a      	mov	r2, r3
  28:	f04f 0300 	mov.w	r3, #0
  2c:	4904      	ldr	r1, [pc, #16]	; (40 &amp;lt;main+0x40&amp;gt;)
  2e:	e9c1 2300 	strd	r2, r3, [r1]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Somewhat related: you might need to upgrade to a processor with double precision FPU too (ARM Cortex-M7 for example) if you want a more powerful FPU.&lt;/P&gt;&lt;P&gt;Keep in mind that there are two things: one thing is to tell the compiler to create instructions matching the FPU in the hardware (this is done through the compiler switches, do not mess with the #defines unless you know exactly what you are doing). The other thing is to enable the FPU in the firmware as usually it is disabled by default, see&amp;nbsp;&lt;A href="https://mcuoneclipse.com/2016/10/29/tutorial-building-freertos-applications-for-arm-cortex-m4-on-i-mx7-with-eclipse/" target="_blank"&gt;https://mcuoneclipse.com/2016/10/29/tutorial-building-freertos-applications-for-arm-cortex-m4-on-i-mx7-with-eclipse/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;If you are new to FPU on ARM Cortex-M4: have a read at&amp;nbsp;&lt;A href="https://mcuoneclipse.com/2019/03/29/be-aware-floating-point-operations-on-arm-cortex-m4f/" target="_blank"&gt;https://mcuoneclipse.com/2019/03/29/be-aware-floating-point-operations-on-arm-cortex-m4f/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2020 07:58:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-enable-FPU-in-MK22FX512AVLQ12/m-p/1197203#M59097</guid>
      <dc:creator>ErichStyger</dc:creator>
      <dc:date>2020-12-10T07:58:00Z</dc:date>
    </item>
  </channel>
</rss>

