Keil Logo

C51: kbhit Library Routine Is Missing

QUESTION

There is no ANSI kbhit routine listed in the C51 manuals and it doesn't seem to be implemented in the library. Why?

ANSWER

There are several reasons that we do not provide a kbhit routine.

The first is that kbhit is not part of the ANSI library. This is a MicroSoft routine.

The second is that the implementation of this routine depends vastly on the application which uses it. Whether you are using polled or serial IO, or even parallel or IR, affects the implementation of this routine. Rather than creating different kbhit routines for every possible application, we leave it up to the developer to create this routine if it is needed.

The functionality of kbhit is simple - check to see if a character is waiting to be processed; if so, return true, if not, return false. The status of the serial buffer in an interrupt-driven app would be checked in the interrupt handler and a flag would be set reflecting whether or not a character was available.

MORE INFORMATION

  • Refer to _getkey in the Cx51 User's Guide.

Last Reviewed: Thursday, February 25, 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.