Technical Support

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: Tuesday, October 24, 2006


Did this article provide the answer you needed?
 
Yes
No
Not Sure