Keil Logo

µVISION DEBUGGER: _GETKEY Doesn't Work With MON51


Information in this article applies to:

  • C51 Version 5 and 6
  • MON51

QUESTION

I'm debugging my program using MON51 and the µVision IDE. I can use printf in my program and see the characters output in the µVision Serial Window. However, when I use _getkey to receive characters in my program, all I get are 0x11 characters.

ANSWER

There are several possible causes of this problem.

  1. If you use the serial interrupt to allow the monitor to stop your target program you may experience problems since the monitor (and not your program) receives any characters that are transmitted. You can check the Debug tab in Project Settings and then click on Settings for the Keil Monitor to find this option.
  2. If you single-step thru the program while transmitting characters, you'll probably get some serial port thrashing between the monitor and the target program. When you single-step, between steps the monitor has control of the serial port. Characters that are transmitted during that time are captured by the monitor and are probably thrown away. Try running the program and then sending characters.
  3. In some cases, µVision interrogates the MON51 target using XON and XOFF characters. If you receive 0x11 or 0x13 characters, this may be the problem you are experiencing. To correct this problem, you must ignore XON and XOFF in your program. If you use the standard GETKEY routine, the following substitute function may be added to your project:
    #include <reg51.h>
    
    char _getkey ()  {
      char c;
    
    do
      {
      while (!RI);
      c = SBUF;
      RI = 0;
      }
    while (c == 0x11 || c == 0x13);   // IGNORE XON and XOFF
    
    return (c);
    }
    

SEE ALSO

Last Reviewed: Friday, January 29, 2021


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.