GENERAL: PRINTF OUTPUT TO MULTIPLE DEVICES -------------------------------------------------------------------------------- Information in this support solution applies to: C166 All Versions C251 All Versions C51 All Versions -------------------------------------------------------------------------------- QUESTION How can I modify printf to output its results to either the serial port or to an LCD panel? ANSWER Yes. The printf function uses putchar to output characters. You should start by referencing the source for the putchar function which is found in the PUTCHAR.C file in the \KEIL\TOOLSET\LIB folder. You may modify the putchar routine to output characters to any number of different targets. For example: #define PUTCHAR_SERIAL 0 #define PUTCHAR_LCD 1 unsigned char putchar_target = PUTCHAR_SERIAL; char putchar (char k) { switch (putchar_target) { default: case PUTCHAR_SERIAL: /*** Code here for output to serial port ***/ break; case PUTCHAR_LCD: /*** Code here for output to LCD ***/ break; } } In this template, you must insert the code necessary to output to the serial port as well as the code necessary to output to the LCD. You may, of course, add more output targets as required by your hardware. In your code, call printf as follows: putchar_target = PUTCHAR_SERIAL; printf ("Hello World\n"); putchar_target = PUTCHAR_LCD; printf ("Hello World\n"); Make sure that you set the target before each call to printf.