<?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 Software Development Kit中的主题 Re: PRINTF %d doesn't handle negative numbers?</title>
    <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/PRINTF-d-doesn-t-handle-negative-numbers/m-p/621242#M6483</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks for your feedback.&lt;/P&gt;&lt;P&gt;I just checked the screenshot, the correct setting is PRINTF_ADVANCED_ENABLE=1.&lt;/P&gt;&lt;P&gt;I just modified the screenshot to the correct one.&lt;/P&gt;&lt;P&gt;the video use setting of PRINTF_ADVANCED_ENABLE=1. it's right.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Jennie Zhang&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 22 Jan 2017 03:41:38 GMT</pubDate>
    <dc:creator>ZhangJennie</dc:creator>
    <dc:date>2017-01-22T03:41:38Z</dc:date>
    <item>
      <title>PRINTF %d doesn't handle negative numbers?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/PRINTF-d-doesn-t-handle-negative-numbers/m-p/621239#M6480</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It appears&amp;nbsp;that PRINTF and related methods don't handle negative numbers:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;#include "fsl_device_registers.h"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;#include "fsl_debug_console.h"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;#include "board.h"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;#include "pin_mux.h"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;#include "clock_config.h"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;/*******************************************************************************&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt; * Definitions&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt; ******************************************************************************/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;/*******************************************************************************&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt; * Prototypes&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt; ******************************************************************************/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;/*******************************************************************************&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt; * Code&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt; ******************************************************************************/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;/*!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt; * @brief Main function&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt; */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;int main(void)&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;&amp;nbsp; char ch;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;&amp;nbsp; int32_t int32;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;&amp;nbsp; /* Init board hardware. */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;&amp;nbsp; BOARD_InitPins();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;&amp;nbsp; BOARD_BootClockRUN();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;&amp;nbsp; BOARD_InitDebugConsole();&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;&amp;nbsp; int32 = -2;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;&amp;nbsp; PRINTF("int32 = 0x%x (%d)\n", int32, int32);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;&amp;nbsp; while (1)&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;&amp;nbsp; &amp;nbsp; ch = GETCHAR();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;&amp;nbsp; &amp;nbsp; PUTCHAR(ch);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The above program prints out:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;int32 = 0xfffffffe (2)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;...rather than&amp;nbsp;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;0xfffffffe (-2)&lt;/SPAN&gt; as I would expect.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am I missing something? &amp;nbsp;Or is this behavior documented somewhere?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS: I'm running KDS 3.2.0 on Mac OSX 10.12.2, compiling for a&amp;nbsp;FRDM-KL27Z board.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jan 2017 18:19:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/PRINTF-d-doesn-t-handle-negative-numbers/m-p/621239#M6480</guid>
      <dc:creator>robertpoor</dc:creator>
      <dc:date>2017-01-16T18:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: PRINTF %d doesn't handle negative numbers?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/PRINTF-d-doesn-t-handle-negative-numbers/m-p/621240#M6481</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Robert,&lt;/P&gt;&lt;P&gt;to print negative number, please:&lt;/P&gt;&lt;P&gt;1.enable PRINTF_ADVANCED_ENABLE=1 in preprocessor setting.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/12656i214F621042E3AA35/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. remove bracket from %d&lt;/P&gt;&lt;P&gt;PRINTF("int32 = 0x%x %d\n", int32, int32);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;see attached video.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Jennie Zhang&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&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>Wed, 18 Jan 2017 10:21:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/PRINTF-d-doesn-t-handle-negative-numbers/m-p/621240#M6481</guid>
      <dc:creator>ZhangJennie</dc:creator>
      <dc:date>2017-01-18T10:21:25Z</dc:date>
    </item>
    <item>
      <title>Re: PRINTF %d doesn't handle negative numbers?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/PRINTF-d-doesn-t-handle-negative-numbers/m-p/621241#M6482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That appears to work, thank you. &amp;nbsp;(But I must point out that it's strange to enable FLOATING POINT in order to print out a negative INTEGER.)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Jan 2017 16:28:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/PRINTF-d-doesn-t-handle-negative-numbers/m-p/621241#M6482</guid>
      <dc:creator>robertpoor</dc:creator>
      <dc:date>2017-01-20T16:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: PRINTF %d doesn't handle negative numbers?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/PRINTF-d-doesn-t-handle-negative-numbers/m-p/621242#M6483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks for your feedback.&lt;/P&gt;&lt;P&gt;I just checked the screenshot, the correct setting is PRINTF_ADVANCED_ENABLE=1.&lt;/P&gt;&lt;P&gt;I just modified the screenshot to the correct one.&lt;/P&gt;&lt;P&gt;the video use setting of PRINTF_ADVANCED_ENABLE=1. it's right.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Jennie Zhang&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 Jan 2017 03:41:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/PRINTF-d-doesn-t-handle-negative-numbers/m-p/621242#M6483</guid>
      <dc:creator>ZhangJennie</dc:creator>
      <dc:date>2017-01-22T03:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: PRINTF %d doesn't handle negative numbers?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/PRINTF-d-doesn-t-handle-negative-numbers/m-p/621243#M6484</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I had this same problem using KL25Z but rather than modify the Preprocessor option like in the picture above, I found out the same definition within fsl_debug_console.h. Before it was defines as "#define PRINTF_ADVANCED_ENABLE 0U", I just change the 0 by 1 and the negative numbers started to appear =).&lt;/P&gt;&lt;P&gt;However I still have a doubt for the SDK staff... Which ones are all of those ADVANCED features that got enabled with this define?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/74607i9996EFCA7B4C9EF3/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Oct 2018 20:25:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/PRINTF-d-doesn-t-handle-negative-numbers/m-p/621243#M6484</guid>
      <dc:creator>danielcolon</dc:creator>
      <dc:date>2018-10-14T20:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: PRINTF %d doesn't handle negative numbers?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/PRINTF-d-doesn-t-handle-negative-numbers/m-p/1263461#M8093</link>
      <description>&lt;P&gt;Amazing for me.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 09:47:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/PRINTF-d-doesn-t-handle-negative-numbers/m-p/1263461#M8093</guid>
      <dc:creator>cmou</dc:creator>
      <dc:date>2021-04-16T09:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: PRINTF %d doesn't handle negative numbers?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/PRINTF-d-doesn-t-handle-negative-numbers/m-p/1269127#M8094</link>
      <description>&lt;P&gt;&lt;BR /&gt;Dear Jennie,&lt;/P&gt;&lt;P&gt;thank you very much, the problem is solved.&lt;/P&gt;&lt;P&gt;However, I have a question: why does this option exist? I mean,&lt;BR /&gt;an option which, if not set, allows printf to print&lt;BR /&gt;"wrong" numbers (i.e. negative numbers which appear to be positive)?&lt;/P&gt;&lt;P&gt;I thank you in advance&lt;BR /&gt;Sergio&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 20:28:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/PRINTF-d-doesn-t-handle-negative-numbers/m-p/1269127#M8094</guid>
      <dc:creator>Sergio_Carrato</dc:creator>
      <dc:date>2021-04-27T20:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: PRINTF %d doesn't handle negative numbers?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/PRINTF-d-doesn-t-handle-negative-numbers/m-p/1832146#M8181</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am facing the similar issue on LPC55. I am using MCUXpresso &lt;SPAN&gt;v11.9.0 [Build 2144] and SDK version 2.15.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have redirected the PRINTF to the SWO output.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If PRINTF_ADVANCED_ENABLE is set to 0, printing works but negative numbers are written as positive.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If I set PRINTF_ADVANCED_ENABLE&amp;nbsp; to 1, after the first printf with a number argument is reached no printfs are working afterwards.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My code is executing several printfs with just text followed by some printfs with numbers.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Best regards&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ugljesa&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 15:22:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/PRINTF-d-doesn-t-handle-negative-numbers/m-p/1832146#M8181</guid>
      <dc:creator>ugljesa_tomanov</dc:creator>
      <dc:date>2024-03-20T15:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: PRINTF %d doesn't handle negative numbers?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/PRINTF-d-doesn-t-handle-negative-numbers/m-p/1832888#M8183</link>
      <description>Problem solved.&lt;BR /&gt;When PRINTF_ADVANCED_ENABLED is set to 1 it increases the needed amount of RAM so my task was running in to stack overflow condition.</description>
      <pubDate>Thu, 21 Mar 2024 10:35:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/PRINTF-d-doesn-t-handle-negative-numbers/m-p/1832888#M8183</guid>
      <dc:creator>ugljesa_tomanov</dc:creator>
      <dc:date>2024-03-21T10:35:07Z</dc:date>
    </item>
  </channel>
</rss>

