<?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: taking console inputs in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/taking-console-inputs/m-p/155607#M3975</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is getchar really working?&lt;/P&gt;&lt;P&gt;(If you wonder, yes, simulator is working and you can do serial I/O to/from terminal window and keyboard).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Aug 2011 13:11:20 GMT</pubDate>
    <dc:creator>kef</dc:creator>
    <dc:date>2011-08-03T13:11:20Z</dc:date>
    <item>
      <title>taking console inputs</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/taking-console-inputs/m-p/155605#M3973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working with CodeWarrior v5.1 the special edition for HCS12.&lt;/P&gt;&lt;P&gt;I figured that I could not use some stdio functions directly here for microcontrollers.&lt;/P&gt;&lt;P&gt;I included the TERMIO.c and TERMIO.h for "printf", it worked. But now I want to take inputs from terminal. I used "scanf" which I have implemented with getchar() in TERMIO. But when I try to simulate the program, I cannot type in anything at terminal.&lt;/P&gt;&lt;P&gt;Anybody know the reason for this problem? Do I have to specify communication port just for taking console inputs? Attached is a simple project.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I'm confused about using those ANSI C functions. It seems most of them are not supported by CodeWarrior compiler. Anyone could direct me to some place that talks about how I could use those functions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Aug 2011 23:04:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/taking-console-inputs/m-p/155605#M3973</guid>
      <dc:creator>Yuping</dc:creator>
      <dc:date>2011-08-01T23:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: taking console inputs</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/taking-console-inputs/m-p/155606#M3974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is anyone here to help??&lt;/P&gt;&lt;P&gt;I checked the Debugger_HC12.pdf file and found that I could change terminal connections to "keyboard --&amp;gt; Virtual SCI".&lt;/P&gt;&lt;P&gt;But it seemed not working...&lt;/P&gt;&lt;P&gt;I think the problem might be from using the "scanf()" function. Could anyone help me with this problem?&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;P&gt;Yuping&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2011 02:41:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/taking-console-inputs/m-p/155606#M3974</guid>
      <dc:creator>Yuping</dc:creator>
      <dc:date>2011-08-03T02:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: taking console inputs</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/taking-console-inputs/m-p/155607#M3975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is getchar really working?&lt;/P&gt;&lt;P&gt;(If you wonder, yes, simulator is working and you can do serial I/O to/from terminal window and keyboard).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2011 13:11:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/taking-console-inputs/m-p/155607#M3975</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2011-08-03T13:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: taking console inputs</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/taking-console-inputs/m-p/155608#M3976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;kef,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for replying!&lt;/P&gt;&lt;P&gt;TERMIO_GetChar() is working. Inspired from your concern, I used this TERMIO_GetChar() function instead of scanf(). The program took the inputs from keyboard.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the output I got from Terminal&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Input a 16-character string:&lt;/P&gt;&lt;P&gt;The string is Test message 01.ZZZZZZZZZZZZZZZZZZZZZZZZZZZZ&lt;/P&gt;&lt;P&gt;84 101 115 116 32 109 101 115 115 97 103 101 32 48 49 46&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is weird that there are some Z's following the message. Do you have any idea about why it happened?&lt;/P&gt;&lt;P&gt;Also, I am confused by the use of TERMIO. Why can I use printf() without any problem, but not scanf()?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is my main.c&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#include &amp;lt;hidef.h&amp;gt;      /* common defines and macros */#include "derivative.h"      /* derivative-specific definitions */#include &amp;lt;TERMIO.h&amp;gt;#include &amp;lt;stdio.h&amp;gt;#include &amp;lt;stdlib.h&amp;gt;void main(void) {  /* put your own code here */  int i;  char words[16];  int asc[16];  TERMIO_Init();    printf("Input a 16-character string:\n");  for(i = 0; i &amp;lt; 16; i++)    words[i] = TERMIO_GetChar();  //scanf("%s",&amp;amp;words);  //fgets(words,strsize,stdin);  printf("The string is %s\n", words);  i = 0;  while(words[i]!='\0') {       asc[i] = (int)words[i];       printf("%d ",asc[i]);       i++;  } EnableInterrupts;  for(;;) {    _FEED_COP(); /* feeds the dog */  } /* loop forever */  /* please make sure that you never leave main */}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 08:59:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/taking-console-inputs/m-p/155608#M3976</guid>
      <dc:creator>Yuping</dc:creator>
      <dc:date>2020-10-29T08:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: taking console inputs</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/taking-console-inputs/m-p/155609#M3977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried it. scanf is working, but for my surprise it requires tons of stack space. scanf routine is defined in lib\src\embedded.c . At top of routine you may see local variable &amp;nbsp; char outbuf[LIBDEF_SCANF_BUF_SIZE]; . LIBDEF_SCANF_BUF_SIZE is set to 255 by default in include\libdefs.h. This means you need to have stack much larger than 255. Either increase stack size in *.prm file or recompile library with reduced LIBDEF_SCANF_BUS_SIZE. You may just add embedded.c to your project and change link priority so that linker&amp;nbsp;links with embedded.c from your project, but not from then library.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Aug 2011 14:40:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/taking-console-inputs/m-p/155609#M3977</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2011-08-04T14:40:59Z</dc:date>
    </item>
    <item>
      <title>Re: taking console inputs</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/taking-console-inputs/m-p/155610#M3978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And you get ZZZZ because your local not initialied string doesn't&amp;nbsp;have '\0' at the end.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Aug 2011 14:54:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/taking-console-inputs/m-p/155610#M3978</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2011-08-04T14:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: taking console inputs</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/taking-console-inputs/m-p/155611#M3979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kef,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot for helping out!&lt;/P&gt;&lt;P&gt;Now I'm able to use scanf correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have another question though...&lt;/P&gt;&lt;P&gt;Since scanf reads console input until it sees a whitespace, I think it may be better to use fgets for convenience...&lt;/P&gt;&lt;P&gt;I couldn't find the file which defines fgets either... I checked CodeWarrior InfoCenter, and did not find the information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you give an insight about where to find function definitions in general? It's really annoying when I have to find those ANSI C functions which cannot be used by just including stdio.h...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yuping&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2011 00:29:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/taking-console-inputs/m-p/155611#M3979</guid>
      <dc:creator>Yuping</dc:creator>
      <dc:date>2011-08-05T00:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: taking console inputs</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/taking-console-inputs/m-p/155612#M3980</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The &lt;EM&gt;Compiler_HC12.pdf&lt;/EM&gt; reference manual states that&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"The ANSI–C library contains a fairly large interface for file I/O. In microcontroller&lt;BR /&gt;applications however, one usually does not need file I/O. In the few cases where one&lt;BR /&gt;would need it, the implementation depends on the actual setup of the target system.&lt;BR /&gt;Therefore, is therefore impossible for Freescale to provide an implementation for these&lt;BR /&gt;features that the user has to specifically implement."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now if you want to read data from a file you can use the terminal redirection feature.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is explained in &lt;EM&gt;Debugger_HC12.pdf&lt;/EM&gt; chapter &lt;STRONG&gt;&lt;EM&gt;Book I Debugger Engine&lt;/EM&gt;&lt;/STRONG&gt; section &lt;EM&gt;&lt;STRONG&gt;Debugger Components&lt;/STRONG&gt;&lt;/EM&gt; &amp;gt; &lt;EM&gt;&lt;STRONG&gt;General Debugger Components&lt;/STRONG&gt;&lt;/EM&gt; &amp;gt; &lt;EM&gt;&lt;STRONG&gt;Terminal Component&lt;/STRONG&gt;&lt;/EM&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;Input and Output File&lt;/STRONG&gt;&lt;/EM&gt; &amp;amp; &lt;EM&gt;&lt;STRONG&gt;File Control Commands&lt;/STRONG&gt;&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2011 13:52:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/taking-console-inputs/m-p/155612#M3980</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2011-08-05T13:52:58Z</dc:date>
    </item>
    <item>
      <title>Re: taking console inputs</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/taking-console-inputs/m-p/155613#M3981</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, CrasyCat!&lt;/P&gt;&lt;P&gt;I got it!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2011 20:49:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/taking-console-inputs/m-p/155613#M3981</guid>
      <dc:creator>Yuping</dc:creator>
      <dc:date>2011-08-05T20:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: taking console inputs</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/taking-console-inputs/m-p/155614#M3982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Would it be a bad idea to make the printf(), scanf(), etc.&amp;nbsp;functions use the SCI module?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Aug 2011 06:11:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/taking-console-inputs/m-p/155614#M3982</guid>
      <dc:creator>AirDragon</dc:creator>
      <dc:date>2011-08-23T06:11:40Z</dc:date>
    </item>
  </channel>
</rss>

