<?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: sprintf() convert float value to string in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/sprintf-convert-float-value-to-string/m-p/1597066#M51592</link>
    <description>&lt;P&gt;In your case, the linker options would be equally important.&lt;BR /&gt;Find out what clib you application is linked against (clib*.a), and if it contains printf floating point support.&lt;BR /&gt;Clib support and library selection depends very much on the toolchain.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Feb 2023 06:28:17 GMT</pubDate>
    <dc:creator>frank_m</dc:creator>
    <dc:date>2023-02-10T06:28:17Z</dc:date>
    <item>
      <title>sprintf() convert float value to string</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/sprintf-convert-float-value-to-string/m-p/1595753#M51565</link>
      <description>&lt;P&gt;I add following code&amp;nbsp; to my main(), when run it. code stuck.&lt;/P&gt;&lt;P&gt;float ft = 3.3;&lt;/P&gt;&lt;P&gt;sprintf( str, "%0.2f\n\r", ft );&lt;BR /&gt;UART0_putString( str );&lt;/P&gt;&lt;P&gt;I read the&amp;nbsp;&lt;A href="https://community.nxp.com/t5/MCUXpresso-IDE/sprintf-not-functioning-correctly/m-p/934239#M4303" target="_blank"&gt;Solved: sprintf not functioning correctly - NXP Community&lt;/A&gt;&lt;BR /&gt;but my MDK, uVision IDE, don't have &lt;SPAN&gt;&lt;U&gt;Project &amp;gt; properties&lt;/U&gt; &amp;gt; C/C++ Build &amp;gt; Setiings &amp;gt; Tool Settings &amp;gt; MCU C Compiler &amp;gt; Preprocessor.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;but have project/options/C/C++/Preprocessor/.&lt;/P&gt;&lt;P&gt;I set&amp;nbsp;PRINTF_FLOAT_ENABLE=1 SCANF_FLOAT_ENABLE=1 CR_INTEGER_PRINTF=1 in Preprocessor. issue won't gone.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 16:34:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/sprintf-convert-float-value-to-string/m-p/1595753#M51565</guid>
      <dc:creator>xianwu</dc:creator>
      <dc:date>2023-02-08T16:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: sprintf() convert float value to string</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/sprintf-convert-float-value-to-string/m-p/1596120#M51576</link>
      <description>&lt;P&gt;Hello, I research more information you could change the version of the ARM compiler, e&lt;SPAN&gt;nable this option in µVision under Project - Options for Target&amp;nbsp;- Code Generation - V6.18.&amp;nbsp;&lt;CODE&gt;-mfloat-abi=&lt;VAR&gt;name&lt;/VAR&gt;&lt;/CODE&gt;&lt;A name="index-mfloat-abi" target="_blank"&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;A href="https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html" target="_blank"&gt;ARM Options (Using the GNU Compiler Collection (GCC))&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Let me know if you have more questions.&lt;/P&gt;
&lt;P&gt;Best&lt;SPAN&gt;&amp;nbsp;regards,&lt;BR /&gt;Pavel&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 02:38:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/sprintf-convert-float-value-to-string/m-p/1596120#M51576</guid>
      <dc:creator>Pavel_Hernandez</dc:creator>
      <dc:date>2023-02-09T02:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: sprintf() convert float value to string</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/sprintf-convert-float-value-to-string/m-p/1596268#M51578</link>
      <description>&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&amp;gt; Hello, I research more information you could change the version of the ARM compiler, enable this option in µVision under Project - Options for Target&amp;nbsp;- Code Generation - V6.18.&amp;nbsp;-mfloat-abi=name&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Problems with printf() - like functions are usually not related to the ABI. Those only influence operations on floating point values.&lt;/P&gt;&lt;P&gt;I suspect the librarcy (clib). Any version with "nano" in it's name supports no floating point formats in printf functions at all.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 06:44:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/sprintf-convert-float-value-to-string/m-p/1596268#M51578</guid>
      <dc:creator>frank_m</dc:creator>
      <dc:date>2023-02-09T06:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: sprintf() convert float value to string</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/sprintf-convert-float-value-to-string/m-p/1596685#M51584</link>
      <description>&lt;P&gt;this is my IDE info, I'm using ARMCC compiler.&amp;nbsp;&lt;BR /&gt;IDE-Version:&lt;BR /&gt;µVision V5.10.0.2&lt;BR /&gt;Copyright (C) 2014 ARM Ltd and ARM Germany GmbH. All rights reserved.&lt;/P&gt;&lt;P&gt;License Information:&lt;BR /&gt;xian localadmin&lt;BR /&gt;wanco&lt;BR /&gt;LIC=----&lt;/P&gt;&lt;P&gt;Tool Version Numbers:&lt;BR /&gt;Toolchain: MDK-Lite Version: 5.10.0.0&lt;BR /&gt;Toolchain Path: C:\Keil_v5\ARM\ARMCC\bin\&lt;BR /&gt;C Compiler: Armcc.Exe V5.04.0.49 [Evaluation]&lt;BR /&gt;Assembler: Armasm.Exe V5.04.0.49 [Evaluation]&lt;BR /&gt;Linker/Locator: ArmLink.Exe V5.04.0.49 [Evaluation]&lt;BR /&gt;Librarian: ArmAr.Exe V5.04.0.49 [Evaluation]&lt;BR /&gt;Hex Converter: FromElf.Exe V5.04.0.49 [Evaluation]&lt;BR /&gt;CPU DLL: SARMCM3.DLL V5.10.0.0&lt;BR /&gt;Dialog DLL: DARMCM1.DLL V1.11.00.0&lt;BR /&gt;Target DLL: CMSIS_AGDI.dll V1.18.4.0&lt;BR /&gt;Dialog DLL: TARMCM1.DLL V1.08.00.0&lt;/P&gt;&lt;P&gt;and the compile option is :&lt;/P&gt;&lt;P&gt;-c --cpu Cortex-M0+ -D__EVAL -g -O0 --apcs=interwork --split_sections -I..\..\Project_Source_Code\peripherals_lib\inc -I..\..\Project_Source_Code\utilities_lib\inc -I..\..\Project_Source_Code\common\inc -I..\..\Project_Source_Code\project\inc -DUSE_SERIAL_DEBUG&lt;BR /&gt;-I C:\Keil_v5\ARM\RV31\INC&lt;BR /&gt;-I C:\Keil_v5\ARM\PACK\ARM\CMSIS\3.20.4\CMSIS\Include&lt;BR /&gt;-I Device\Include&lt;BR /&gt;-o ".\Objects\*.o" --omf_browse ".\Objects\*.crf" --depend ".\Objects\*.d"&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 15:12:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/sprintf-convert-float-value-to-string/m-p/1596685#M51584</guid>
      <dc:creator>xianwu</dc:creator>
      <dc:date>2023-02-09T15:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: sprintf() convert float value to string</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/sprintf-convert-float-value-to-string/m-p/1597066#M51592</link>
      <description>&lt;P&gt;In your case, the linker options would be equally important.&lt;BR /&gt;Find out what clib you application is linked against (clib*.a), and if it contains printf floating point support.&lt;BR /&gt;Clib support and library selection depends very much on the toolchain.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 06:28:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/sprintf-convert-float-value-to-string/m-p/1597066#M51592</guid>
      <dc:creator>frank_m</dc:creator>
      <dc:date>2023-02-10T06:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: sprintf() convert float value to string</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/sprintf-convert-float-value-to-string/m-p/1597494#M51599</link>
      <description>&lt;P&gt;I checked in my toolchain folder. did not clib*.a or clib*.&amp;nbsp;&lt;/P&gt;&lt;P&gt;the toolchain is from ARM, called ARMCC.&amp;nbsp;&lt;/P&gt;&lt;P&gt;from the IDE, it's hard to tell which lib is used. and it is weird that the toolchain proved by ARM has issue with sprintf().&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Xian&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 16:53:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/sprintf-convert-float-value-to-string/m-p/1597494#M51599</guid>
      <dc:creator>xianwu</dc:creator>
      <dc:date>2023-02-10T16:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: sprintf() convert float value to string</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/sprintf-convert-float-value-to-string/m-p/1597581#M51602</link>
      <description>&lt;P&gt;When I add sprintf(str, "%f", x);&amp;nbsp;&lt;/P&gt;&lt;P&gt;following info showed in the buildt map file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;when x =5.5;&amp;nbsp;&amp;nbsp;it prints out 5y500000. it's partially works.&amp;nbsp;&lt;/P&gt;&lt;P&gt;main.o(i.main) refers to _printf_f.o(.ARM.Collect$$_printf_percent$$00000003) for _printf_f&lt;BR /&gt;main.o(i.main) refers to printf1.o(x$fpl$printf1) for _printf_fp_dec&lt;/P&gt;&lt;P&gt;main.o(i.main) refers to f2d.o(.text) for __aeabi_f2d&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 20:25:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/sprintf-convert-float-value-to-string/m-p/1597581#M51602</guid>
      <dc:creator>xianwu</dc:creator>
      <dc:date>2023-02-10T20:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: sprintf() convert float value to string</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/sprintf-convert-float-value-to-string/m-p/1597901#M51614</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; following info showed in the buildt map file.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;To check the map file output would have been one of my suggestions. Many toolchains can output cross reference lists as well, including details where a symbol (e.g. function) originates from.&lt;BR /&gt;But as said, I don' have the ARM toolchain at ma disposal to test it. In fact I have very little experience with MDK.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Have you tried tutorials and documentations ?&lt;BR /&gt;I suppose the linker and library options are well documented.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;And, at least in POSIX compatible platforms, the printf format character 'f' denotes a double argument, not a (single precision) float argument :&amp;nbsp;&lt;A href="https://linux.die.net/man/3/printf" target="_blank"&gt;https://linux.die.net/man/3/printf&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;By the way ...&lt;BR /&gt;in this expression "&lt;FONT face="courier new,courier"&gt;float ft = 3.3;&lt;/FONT&gt;", the constant "3.3" represents a double, not a float.&lt;BR /&gt;The stated assignment involves an implicit type conversion (from double to float), which has very little effect in your case.&lt;BR /&gt;You can avoid that by adding the specific suffix, i.e. "&lt;FONT face="courier new,courier"&gt;float fp = 3.3&lt;STRONG&gt;f&lt;/STRONG&gt;;&lt;/FONT&gt;".&lt;BR /&gt;Only in more extensive floating point calculations like spectral algorithms or tight cycle-by-cycle control loops, it can make a substantial difference.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 06:38:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/sprintf-convert-float-value-to-string/m-p/1597901#M51614</guid>
      <dc:creator>frank_m</dc:creator>
      <dc:date>2023-02-13T06:38:23Z</dc:date>
    </item>
    <item>
      <title>Re: sprintf() convert float value to string</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/sprintf-convert-float-value-to-string/m-p/1599017#M51633</link>
      <description>&lt;P&gt;thank you all for help.&lt;/P&gt;&lt;P&gt;I figured it out. in Keil IDE , Project/option for target,&amp;nbsp; seeting select MicroLIB option.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 17:10:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/sprintf-convert-float-value-to-string/m-p/1599017#M51633</guid>
      <dc:creator>xianwu</dc:creator>
      <dc:date>2023-02-14T17:10:33Z</dc:date>
    </item>
  </channel>
</rss>

