<?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 Writing to a file (fprintf) in MCUXpresso IDE (11.3.1) in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Writing-to-a-file-fprintf-in-MCUXpresso-IDE-11-3-1/m-p/1289245#M45355</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am wanting to print contents to a file using the C function "fprintf," but I cannot get the code to work properly. Here is my code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;FILE *analog_values = fopen("analog_values.txt", "w");&lt;BR /&gt;if (analog_values == NULL)&lt;BR /&gt;{&lt;BR /&gt;PRINTF("File could not be opened\n");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;FPRINTF(analog_values, "%d\n", g_LpadcResultConfigStruct.convValue &amp;gt;&amp;gt; g_LpadcResultShift);&lt;/P&gt;&lt;P&gt;fclose(analog_values);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run this code, I receive "File could not be opened" in the terminal every time, and the rest of my code (not shown here) does not run. If anyone can help, I would greatly appreciate it.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
    <pubDate>Tue, 08 Jun 2021 14:52:49 GMT</pubDate>
    <dc:creator>caden013</dc:creator>
    <dc:date>2021-06-08T14:52:49Z</dc:date>
    <item>
      <title>Writing to a file (fprintf) in MCUXpresso IDE (11.3.1)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Writing-to-a-file-fprintf-in-MCUXpresso-IDE-11-3-1/m-p/1289245#M45355</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am wanting to print contents to a file using the C function "fprintf," but I cannot get the code to work properly. Here is my code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;FILE *analog_values = fopen("analog_values.txt", "w");&lt;BR /&gt;if (analog_values == NULL)&lt;BR /&gt;{&lt;BR /&gt;PRINTF("File could not be opened\n");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;FPRINTF(analog_values, "%d\n", g_LpadcResultConfigStruct.convValue &amp;gt;&amp;gt; g_LpadcResultShift);&lt;/P&gt;&lt;P&gt;fclose(analog_values);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run this code, I receive "File could not be opened" in the terminal every time, and the rest of my code (not shown here) does not run. If anyone can help, I would greatly appreciate it.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jun 2021 14:52:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Writing-to-a-file-fprintf-in-MCUXpresso-IDE-11-3-1/m-p/1289245#M45355</guid>
      <dc:creator>caden013</dc:creator>
      <dc:date>2021-06-08T14:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to a file (fprintf) in MCUXpresso IDE (11.3.1)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Writing-to-a-file-fprintf-in-MCUXpresso-IDE-11-3-1/m-p/1289255#M45356</link>
      <description>&lt;P&gt;1. Make sure you use fprintf instead of FPRINTF (to avoid the macros)&lt;/P&gt;&lt;P&gt;2. Make sure you are using the semihosting version of the library. Either Redlib (semihost), Newlib (semihost) or NewlibNano (semihost) from the Quick Settings&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2021-06-08 at 16.02.54.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/146599i4AB5E8956D246EE4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2021-06-08 at 16.02.54.png" alt="Screenshot 2021-06-08 at 16.02.54.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jun 2021 15:03:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Writing-to-a-file-fprintf-in-MCUXpresso-IDE-11-3-1/m-p/1289255#M45356</guid>
      <dc:creator>converse</dc:creator>
      <dc:date>2021-06-08T15:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to a file (fprintf) in MCUXpresso IDE (11.3.1)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Writing-to-a-file-fprintf-in-MCUXpresso-IDE-11-3-1/m-p/1289266#M45357</link>
      <description>&lt;P&gt;Thanks for the quick response.&lt;/P&gt;&lt;P&gt;I should have mentioned that I used a macro to define FPRINTF as fprintf -- just to maintain the formatting like the other functions (PRINTF, GETCHAR, SCANF, etc.).&amp;nbsp;&lt;/P&gt;&lt;P&gt;From the quick settings, I can access the "Set library/header type" tab, but all the options are grey and inaccessible. How can I go about fixing this issue?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jun 2021 15:13:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Writing-to-a-file-fprintf-in-MCUXpresso-IDE-11-3-1/m-p/1289266#M45357</guid>
      <dc:creator>caden013</dc:creator>
      <dc:date>2021-06-08T15:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to a file (fprintf) in MCUXpresso IDE (11.3.1)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Writing-to-a-file-fprintf-in-MCUXpresso-IDE-11-3-1/m-p/1289298#M45358</link>
      <description>&lt;P&gt;Suggest you use the lower case functions calls (printf, scan etc) as the UPPER CASE are macro's and their actual function depends on the header files used, and the setting of various #defines. Suggest you read the section of the User Guide on C/C++ support - this describes how to use the sim hosting libraries and the use of printf (and macros etc)&lt;/P&gt;&lt;P&gt;Make sure the correct project is selected in project explorer to ensure the library types are selectable.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jun 2021 16:26:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Writing-to-a-file-fprintf-in-MCUXpresso-IDE-11-3-1/m-p/1289298#M45358</guid>
      <dc:creator>converse</dc:creator>
      <dc:date>2021-06-08T16:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to a file (fprintf) in MCUXpresso IDE (11.3.1)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Writing-to-a-file-fprintf-in-MCUXpresso-IDE-11-3-1/m-p/1289343#M45360</link>
      <description>&lt;P&gt;Thank you -- that seemed to work. My code now creates a file -- exactly what I want it to do. However, the file is blank, and I can't seem to get anything to print into it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the following line of code to print to my file:&amp;nbsp;&lt;/P&gt;&lt;P&gt;fprintf(analog_values, "%d\n", (g_LpadcResultConfigStruct.convValue) &amp;gt;&amp;gt; g_LpadcResultShift);&lt;/P&gt;&lt;P&gt;Is there something wrong with this line, or is the problem somewhere else?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jun 2021 18:29:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Writing-to-a-file-fprintf-in-MCUXpresso-IDE-11-3-1/m-p/1289343#M45360</guid>
      <dc:creator>caden013</dc:creator>
      <dc:date>2021-06-08T18:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to a file (fprintf) in MCUXpresso IDE (11.3.1)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Writing-to-a-file-fprintf-in-MCUXpresso-IDE-11-3-1/m-p/1289361#M45361</link>
      <description>&lt;P&gt;Do you ever fclose the file? If not, try fflush. The data is probably cached.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jun 2021 19:18:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Writing-to-a-file-fprintf-in-MCUXpresso-IDE-11-3-1/m-p/1289361#M45361</guid>
      <dc:creator>converse</dc:creator>
      <dc:date>2021-06-08T19:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to a file (fprintf) in MCUXpresso IDE (11.3.1)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Writing-to-a-file-fprintf-in-MCUXpresso-IDE-11-3-1/m-p/1289368#M45362</link>
      <description>&lt;P&gt;I used the fflush function before and after the fprintf statement to no avail. Here is the code that I am using now:&lt;/P&gt;&lt;P&gt;FILE *analog_values = fopen("analog_values.txt", "w");&lt;/P&gt;&lt;P&gt;int x = 0;&lt;/P&gt;&lt;P&gt;while (x &amp;lt; 500)&lt;BR /&gt;{&lt;BR /&gt;LPADC_DoSoftwareTrigger(DEMO_LPADC_BASE, 1U); /* 1U is trigger0 mask. */&lt;BR /&gt;while (!g_LpadcConversionCompletedFlag)&lt;BR /&gt;{&lt;BR /&gt;}&lt;BR /&gt;PRINTF("ADC value: %d\r\n",&lt;BR /&gt;((g_LpadcResultConfigStruct.convValue) &amp;gt;&amp;gt; g_LpadcResultShift));&lt;BR /&gt;g_LpadcConversionCompletedFlag = false;&lt;/P&gt;&lt;P&gt;if (analog_values == NULL)&lt;BR /&gt;{&lt;BR /&gt;PRINTF("File could not be opened\n");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;fprintf(analog_values, "%d\n", (g_LpadcResultConfigStruct.convValue) &amp;gt;&amp;gt; g_LpadcResultShift);&lt;BR /&gt;fflush(analog_values);&lt;/P&gt;&lt;P&gt;if ( (int)g_LpadcResultConfigStruct.convValue &amp;gt; 0 &amp;amp;&amp;amp; (int)g_LpadcResultConfigStruct.convValue &amp;lt; 16384)&lt;BR /&gt;{&lt;BR /&gt;GPIO_PinWrite(GPIO, BOARD_LED_RED_GPIO_PORT, BOARD_LED_RED_GPIO_PIN, 1);&lt;BR /&gt;GPIO_PinWrite(GPIO, BOARD_LED_GREEN_GPIO_PORT, BOARD_LED_GREEN_GPIO_PIN, 0);&lt;BR /&gt;GPIO_PinWrite(GPIO, BOARD_LED_BLUE_GPIO_PORT, BOARD_LED_BLUE_GPIO_PIN, 0);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;else if ( (int)g_LpadcResultConfigStruct.convValue &amp;gt; 16384 &amp;amp;&amp;amp; (int)g_LpadcResultConfigStruct.convValue &amp;lt; 32768)&lt;BR /&gt;{&lt;BR /&gt;GPIO_PinWrite(GPIO, BOARD_LED_RED_GPIO_PORT, BOARD_LED_RED_GPIO_PIN, 0);&lt;BR /&gt;GPIO_PinWrite(GPIO, BOARD_LED_GREEN_GPIO_PORT, BOARD_LED_GREEN_GPIO_PIN, 1);&lt;BR /&gt;GPIO_PinWrite(GPIO, BOARD_LED_BLUE_GPIO_PORT, BOARD_LED_BLUE_GPIO_PIN, 0);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;else if ( (int)g_LpadcResultConfigStruct.convValue &amp;gt; 32768 &amp;amp;&amp;amp; (int)g_LpadcResultConfigStruct.convValue &amp;lt; 49152)&lt;BR /&gt;{&lt;BR /&gt;GPIO_PinWrite(GPIO, BOARD_LED_RED_GPIO_PORT, BOARD_LED_RED_GPIO_PIN, 0);&lt;BR /&gt;GPIO_PinWrite(GPIO, BOARD_LED_GREEN_GPIO_PORT, BOARD_LED_GREEN_GPIO_PIN, 0);&lt;BR /&gt;GPIO_PinWrite(GPIO, BOARD_LED_BLUE_GPIO_PORT, BOARD_LED_BLUE_GPIO_PIN, 1);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;else if ((int)g_LpadcResultConfigStruct.convValue &amp;gt; 49152 &amp;amp;&amp;amp; (int)g_LpadcResultConfigStruct.convValue &amp;lt; 65536)&lt;BR /&gt;{&lt;BR /&gt;GPIO_PinWrite(GPIO, BOARD_LED_RED_GPIO_PORT, BOARD_LED_RED_GPIO_PIN, 1);&lt;BR /&gt;GPIO_PinWrite(GPIO, BOARD_LED_GREEN_GPIO_PORT, BOARD_LED_GREEN_GPIO_PIN, 1);&lt;BR /&gt;GPIO_PinWrite(GPIO, BOARD_LED_BLUE_GPIO_PORT, BOARD_LED_BLUE_GPIO_PIN, 1);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;else&lt;BR /&gt;{&lt;BR /&gt;GPIO_PinWrite(GPIO, BOARD_LED_RED_GPIO_PORT, BOARD_LED_RED_GPIO_PIN, 1);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;x++;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;fclose(analog_values);&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jun 2021 19:25:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Writing-to-a-file-fprintf-in-MCUXpresso-IDE-11-3-1/m-p/1289368#M45362</guid>
      <dc:creator>caden013</dc:creator>
      <dc:date>2021-06-08T19:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to a file (fprintf) in MCUXpresso IDE (11.3.1)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Writing-to-a-file-fprintf-in-MCUXpresso-IDE-11-3-1/m-p/1290743#M45410</link>
      <description>&lt;P&gt;I want to know please, where we can find the created file (on the computer or on the flash memory of the microcontroller)&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 12:40:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Writing-to-a-file-fprintf-in-MCUXpresso-IDE-11-3-1/m-p/1290743#M45410</guid>
      <dc:creator>MK001</dc:creator>
      <dc:date>2021-06-10T12:40:48Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to a file (fprintf) in MCUXpresso IDE (11.3.1)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Writing-to-a-file-fprintf-in-MCUXpresso-IDE-11-3-1/m-p/1290791#M45414</link>
      <description>&lt;P&gt;The created file will be in the same folder as the source code, which creates the file.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 14:19:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Writing-to-a-file-fprintf-in-MCUXpresso-IDE-11-3-1/m-p/1290791#M45414</guid>
      <dc:creator>caden013</dc:creator>
      <dc:date>2021-06-10T14:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to a file (fprintf) in MCUXpresso IDE (11.3.1)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Writing-to-a-file-fprintf-in-MCUXpresso-IDE-11-3-1/m-p/1912034#M56495</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a similar problem of yours, my code is as below (only parts). Both &lt;EM&gt;fprintf&lt;/EM&gt;&amp;nbsp;and&amp;nbsp;&lt;EM&gt;fputs&lt;/EM&gt; don't work. The file &lt;EM&gt;"fromIC.txt"&lt;/EM&gt; is made well in the "&lt;EM&gt;doc"&lt;/EM&gt; folder of my SDKs. Would you please teach me how to write .csv or .txt file from MCUXpresso IDE?. My MCU is QN9080, and library is Redlib(semihost). I also attach the error message.&lt;/P&gt;&lt;P&gt;Please help me;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;STRONG&gt;FILE* datas;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;datas = fopen("fromIC.txt", "w");&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;int inter = 123;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;char str[] = "string ccc";&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;// fprintf(datas, "integer: %d", inter);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;fputs(str, datas);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;fclose(datas);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mjkimbravo_0-1721377492798.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/289351i08D4329563999DA8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mjkimbravo_0-1721377492798.png" alt="mjkimbravo_0-1721377492798.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mjkimbravo_1-1721377657345.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/289352iDE3DC33CC39BF0E8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mjkimbravo_1-1721377657345.png" alt="mjkimbravo_1-1721377657345.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 19 Jul 2024 08:29:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Writing-to-a-file-fprintf-in-MCUXpresso-IDE-11-3-1/m-p/1912034#M56495</guid>
      <dc:creator>mjkimbravo</dc:creator>
      <dc:date>2024-07-19T08:29:20Z</dc:date>
    </item>
  </channel>
</rss>

