Stream I/O Routines
| Routine | Attributes | Description |
|---|
| getchar | | Reads and echoes a character using the _getkey and putchar routines. |
| _getkey | | Reads a character using the serial interface. |
| gets | | Reads and echoes a character string using the getchar routine. |
| printf | | Writes formatted data using the putchar routine. |
| putchar | | Writes a character using the serial interface. |
| puts | reentrant | Writes a character string and newline ('\n') character using the putchar routine. |
| scanf | | Reads formatted data using the getchar routine. |
| sprintf | reentrant | Writes formatted data to a string. |
| sscanf | reentrant | Reads formatted data from a string. |
| ungetchar | | Places a character back into the getchar input buffer. |
| vprintf | | Writes formatted data using the putchar function. |
| vsprintf | reentrant | Writes formatted data to a string. |
The stream I/O routines are implemented as functions and are prototyped in the stdio.h include file.
The stream input and output routines allow you to read and write data to and from a user-defined I/O interface. Characters are read using the _getkey routine and are written using the putchar routine. The default _getkey and putchar functions in the library read and write characters using the C16x serial interface.
The source code for _getkey and putchar is available in the \KEIL\C166\LIB folder. You may modify these files and substitute them for the default library routines. The stream functions then perform input and output using your modified _getkey and putchar routines.
To use the existing _getkey and putchar routines, you must first initialize the serial port. If the serial port is not properly initialized, the default stream functions do not function. Initializing the serial port requires manipulating several special function registers (SFRs).