<?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: Problems with printf variable argument parsing in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problems-with-printf-variable-argument-parsing/m-p/352013#M11253</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like my problem was that printf was called before the UART (and the processor itself)&amp;nbsp; was properly initialized. I added a test to make sure the UART interrupt was installed and the receiver and transmitter was initialized and to problem went away.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This was a good exercise since we discovered that the EWL libraries use RAM-based file handles (stdout which equals struct _FILE _files[1]) to store the UART accessor function pointers (ReadUARTN, WriteUARTN). Using a ram-based function pointer that is never refreshed is unacceptable to us. We will be making our own printf-equivalent that calls our UART routines directly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 Feb 2015 19:11:21 GMT</pubDate>
    <dc:creator>thoborawski</dc:creator>
    <dc:date>2015-02-06T19:11:21Z</dc:date>
    <item>
      <title>Problems with printf variable argument parsing</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problems-with-printf-variable-argument-parsing/m-p/352008#M11248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For Codewarrior V10.5 with EWL, I have been having problems getting&lt;BR /&gt;printf to process the argument list correctly.&amp;nbsp; As an example, for two&lt;/P&gt;&lt;P&gt;test variables:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&lt;EM&gt;unsigned short locTestNum = 5;&lt;/EM&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #3366ff;"&gt;&lt;EM&gt;float locTestFloat = 1.234;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I execute: &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #0000ff;"&gt;printf("{Float=%8.3f} {Int= %hu}\n",locTestFloat,locTestNum);&lt;/EM&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result is:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;{Float=0.000} {Int= 5}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I realize that there are library build options (such as&lt;BR /&gt;_EWL_FLOATING_POINT_PRINTF_SCANF) that may cause such a problem, but I have used sprintf &lt;BR /&gt;in the past with floats with no problems.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As a sidenote: I found that I had to initialize the stdout file handle&lt;BR /&gt;to get printf to work via WriteUARTN. The following are the settings I used:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;stdout-&amp;gt;mode.open_mode = __create_if_necessary;&lt;BR /&gt;stdout-&amp;gt;mode.buffer_mode = _IONBF;&lt;BR /&gt;stdout-&amp;gt;mode.io_mode = __write_mode;&lt;BR /&gt;stdout-&amp;gt;mode.file_kind = __console_file;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;stdout-&amp;gt;state.error = 0;&lt;BR /&gt;stdout-&amp;gt;state.io_state = __writing;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;stdout-&amp;gt;write_proc =&amp;nbsp; __write_console;&amp;nbsp; //located in /src/sys/uart_console_io.c calls WriteUARTN directly&lt;BR /&gt;stdout-&amp;gt;read_proc =&amp;nbsp; __read_console;&lt;BR /&gt;stdout-&amp;gt;buffer = stdout_buff;&lt;BR /&gt;stdout-&amp;gt;buffer_ptr = stdout_buff;&lt;BR /&gt;stdout-&amp;gt;buffer_size = sizeof(stdout_buff);&lt;BR /&gt;stdout-&amp;gt;buffer_len = sizeof(stdout_buff);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2015 16:47:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problems-with-printf-variable-argument-parsing/m-p/352008#M11248</guid>
      <dc:creator>thoborawski</dc:creator>
      <dc:date>2015-02-05T16:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with printf variable argument parsing</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problems-with-printf-variable-argument-parsing/m-p/352009#M11249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tho,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what is the architecture used ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seems you used the printf functions without problem with older version.&lt;/P&gt;&lt;P&gt;What was this version ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;Pascal&lt;BR /&gt;Freescale Technical Support&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2015 14:13:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problems-with-printf-variable-argument-parsing/m-p/352009#M11249</guid>
      <dc:creator>trytohelp</dc:creator>
      <dc:date>2015-02-06T14:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with printf variable argument parsing</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problems-with-printf-variable-argument-parsing/m-p/352010#M11250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We are working in a bareboard project with the MK60FX512. We have only used Codewarrior V10.5&amp;nbsp; for this processor.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2015 15:58:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problems-with-printf-variable-argument-parsing/m-p/352010#M11250</guid>
      <dc:creator>thoborawski</dc:creator>
      <dc:date>2015-02-06T15:58:02Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with printf variable argument parsing</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problems-with-printf-variable-argument-parsing/m-p/352011#M11251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tho,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You've always used CW for MCU v10.5 ?&lt;/P&gt;&lt;P&gt;What does this means "I have used sprintf in the past with floats with no problems." ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By default when you create a project with the wizard you can select 2 options:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt; I/O support&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt; ARM Build Tools&lt;/P&gt;&lt;P&gt;Depending of the options selected this could have an impact of your project - libraries included.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/50306iBDC698AE37D3F911/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_2.png" alt="pastedImage_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Pascal&lt;BR /&gt;Freescale Technical Support&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2015 17:11:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problems-with-printf-variable-argument-parsing/m-p/352011#M11251</guid>
      <dc:creator>trytohelp</dc:creator>
      <dc:date>2015-02-06T17:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with printf variable argument parsing</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problems-with-printf-variable-argument-parsing/m-p/352012#M11252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What I mean by "I have used sprintf in the past with floats with no problem" is that it has worked in the past on other projects&lt;/P&gt;&lt;P&gt;with no problems.&amp;nbsp; Now it does not seem to work correctly. I setup the project with hard float, the UART box checked as you show in your screenshot along with the GCC option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also have the librarian setup for model ewl and print formats "int_FP" as shown below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="x.png (2).png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/50295iD5DCDD686D10857C/image-size/large?v=v2&amp;amp;px=999" role="button" title="x.png (2).png" alt="x.png (2).png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2015 17:44:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problems-with-printf-variable-argument-parsing/m-p/352012#M11252</guid>
      <dc:creator>thoborawski</dc:creator>
      <dc:date>2015-02-06T17:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with printf variable argument parsing</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problems-with-printf-variable-argument-parsing/m-p/352013#M11253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like my problem was that printf was called before the UART (and the processor itself)&amp;nbsp; was properly initialized. I added a test to make sure the UART interrupt was installed and the receiver and transmitter was initialized and to problem went away.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This was a good exercise since we discovered that the EWL libraries use RAM-based file handles (stdout which equals struct _FILE _files[1]) to store the UART accessor function pointers (ReadUARTN, WriteUARTN). Using a ram-based function pointer that is never refreshed is unacceptable to us. We will be making our own printf-equivalent that calls our UART routines directly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2015 19:11:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problems-with-printf-variable-argument-parsing/m-p/352013#M11253</guid>
      <dc:creator>thoborawski</dc:creator>
      <dc:date>2015-02-06T19:11:21Z</dc:date>
    </item>
  </channel>
</rss>

