<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>nRF52 and float printf</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/11362/nrf52-and-float-printf</link><description>Hello, 
 float in printf return blank. How to activate it ? 
 Thank you.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 22 Jan 2016 08:31:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/11362/nrf52-and-float-printf" /><item><title>RE: nRF52 and float printf</title><link>https://devzone.nordicsemi.com/thread/42815?ContentTypeID=1</link><pubDate>Fri, 22 Jan 2016 08:31:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:88d45f3a-0c94-4f21-815c-6a3114fa17ff</guid><dc:creator>Fabien Comte</dc:creator><description>&lt;p&gt;I will try, thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 and float printf</title><link>https://devzone.nordicsemi.com/thread/42816?ContentTypeID=1</link><pubDate>Mon, 18 Jan 2016 10:18:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fee9128e-e6bc-439c-a906-deef3bacf217</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;In Keil
Settings-&amp;gt;Target-&amp;gt;Floating Point Hardware -&amp;gt; Use single presecision&lt;/p&gt;
&lt;p&gt;This will do nothiing but just set some compiler macros in core_cm4.h&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#elif defined ( __ICCARM__ )
  #if defined __ARMVFP__
    #if (__FPU_PRESENT == 1U)
      #define __FPU_USED       1U
    #else
      #error &amp;quot;Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)&amp;quot;
      #define __FPU_USED       0U
    #endif
  #else
    #define __FPU_USED         0U
  #endif
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is  inturn used in system_nrf52.c-&amp;gt;SystemInit()&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#if (__FPU_USED == 1)
    SCB-&amp;gt;CPACR |= (3UL &amp;lt;&amp;lt; 20) | (3UL &amp;lt;&amp;lt; 22); 
    __DSB();
    __ISB();
#endif
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then your compiler will generate hardware floating point instructions and your printf shouldl work normally.&lt;/p&gt;
&lt;p&gt;If you have MicroLib set in Settings-&amp;gt;Target-&amp;gt;Use MicroLIB, then i think it optimizes float instructions. I am not sure how it works here, but i suspect floating point calculations will be tricky. I never use MicroLIB when i want software float.&lt;/p&gt;
&lt;p&gt;If you do not want to use avialable VFP hardware in nRF52(i cannot imagine why not but its your choice). Then you can add&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Settings-&amp;gt;Target-&amp;gt;Floating Point Hardware -&amp;gt; Use single presecision
Settings-&amp;gt;C/C++-&amp;gt;Misc controls-&amp;gt;--fpu=softvfp
Settings-&amp;gt;Linker-&amp;gt;Misc controls-&amp;gt;--fpu=softvfp
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 and float printf</title><link>https://devzone.nordicsemi.com/thread/42814?ContentTypeID=1</link><pubDate>Mon, 18 Jan 2016 03:14:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82ade66d-a776-4a87-9d7d-f5ecfb93f66c</guid><dc:creator>monpetit</dc:creator><description>&lt;p&gt;If you use Eclipse:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/printf_5F00_float.jpg" alt="image description" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>