ARM Technical Support Knowledge Articles


Applies to: C51 C Compiler



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


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.


Article last edited on: 2006-10-24 09:52:01

Rate this article

Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential