<?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>Using float with sprintf generates hardware fault</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/2354/using-float-with-sprintf-generates-hardware-fault</link><description>nRF51 SDK_v5.2.0.39364
GNU Compiler version 4.7 2013q1
Eclipse Juno SR2
nRF51822 Development Kit 
 uint8_t str[128]; //Declared globally 
 float tempval;
tempval = measure_temperature();
memset(&amp;amp;str[0], 0, 128);
sprintf((char*)&amp;amp;str[0], &amp;quot;%3.2f</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 28 Apr 2014 16:10:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/2354/using-float-with-sprintf-generates-hardware-fault" /><item><title>RE: Using float with sprintf generates hardware fault</title><link>https://devzone.nordicsemi.com/thread/9660?ContentTypeID=1</link><pubDate>Mon, 28 Apr 2014 16:10:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0ac798f-d3e9-46bb-98fa-d8a019767013</guid><dc:creator>Karthik</dc:creator><description>&lt;p&gt;Wow, adding
LDFLAGS += --specs=nano.specs
to my makefile made this problem disappear.&lt;/p&gt;
&lt;p&gt;Thanks a ton.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using float with sprintf generates hardware fault</title><link>https://devzone.nordicsemi.com/thread/9659?ContentTypeID=1</link><pubDate>Mon, 28 Apr 2014 14:14:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e546b25-a740-4c93-9651-7d33c03af200</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;Hi Karthik,
Its working for me. I&amp;#39;ve added this code in the timer handler called from the scheduler.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
 float tempval;
 uint32_t n;
 tempval = 128.54;
 memset(&amp;amp;str[0], 0, 128);
 n = sprintf((char*)&amp;amp;str[0], &amp;quot;%3.2f&amp;quot;, tempval);
 printf (&amp;quot;[%s] is a string %d chars long\n&amp;quot;,str,n);

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;where str is a global uint8_t variable of 128 octet length. The string &amp;gt; [128.54] is a string 6 chars long
is printed every second, from the timer handler.
The linker flags used are&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;LDFLAGS = -Xlinker
LDFLAGS += -Map=$(BIN_DIR)/$(OUTPUT_NAME).map
LDFLAGS += --specs=nano.specs
LDFLAGS += -u _printf_float
LDFLAGS += -mcpu=$(CPU) 
LDFLAGS += -mthumb 
LDFLAGS += -mabi=aapcs 
LDFLAGS += -T$(LD_SCRIPT)
LDFLAGS	+= -D$(DEVICE)
LDFLAGS	+= -D$(BOARD)
LDFLAGS += -D$(BLE_REQD)
LDFLAGS	+= $(patsubst %,-L%, $(LDDIRS))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The difference that I see are that i am not specifying the mfloat-abi option, while I am using the nano library for printf and sprintf. See if this works.
Cheers,
Prithvi&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>