AnsweredAssumed Answered

Configuring Console I/O in Processor expert for Freedom KL-25Z

Question asked by Lance Halsted on Oct 7, 2013
Latest reply on Nov 20, 2013 by Pascal Irrle

I recently took a DwF course on Processor Expert and MQX lite. One of the labs used PE to configure console I/O for input (using getchar) and output (using printf). When I follow the lab now, the getchar() function returns something even when nothing is typed, so the program continually scrolls the output. Even when I import the board configuration from the actual class it does not work correctly - the output continually scrolls with the "Invalid Selection" message.

Is there something that needs configuring on the Console I/O component so that getchar() will work correctly? I'm using CodeWarrior 10.5 and the CodeWarrior Terminal window (but HyperTerminal and TeraTerm do the same thing.). The code is:

 

  while(1)

  {

      printf("Welcome to the PEx Serial Console\n");

      printf("Select from the following menu:  \n\n");

      printf("1 :  Blink Red LED\n");

      printf("2 :  Stop Blinking Red LED\n");

      temp_char = getchar();

      if (temp_char == '1')

      {

          printf("\nBlinking Red LED\n\n");

          BlinkTimer_Enable(NULL);

      }

      else if (temp_char == '2')

      {

          printf("\nNot Blinking Red LED\n\n");

          // Stop timer and turn off LED

          BlinkTimer_Disable(NULL);

          RedLED_PutVal(NULL, 1);

      }

      else

          printf("\n\nInvalid Selection!!!\n\n");

  }

Outcomes