I want to use PRINTF function to send different data to ASC0 and ASC1 simultaneosly. If i change _getkey and putchar in LIB for ASC1, so PRINTF will send data to ASC1. How to write new PRINTF_1 for ASC1 while using PRINTF from stdio.h with ASC0?
If you can guarantee that in your application printf for ASC0 and ASC1 will not be called simultaneously (no reentrancy for printf), then you can do a simple trick:
/* define a global flag somewhere */ bit asc_to_use = 0; char putchar(char c) { switch ( asc_to_use ) { case 0: /* send byte using ASC0 */ break; case 1: /* send byte using ASC1 */ } }
Did you say about changing putchar directly in C166\LIB\PUTCHAR.C?
"Did you say about changing putchar directly in C166\LIB\PUTCHAR.C?" That is the default version supplied by Keil - you probably want to keep that! It's probably better to copy that file to (one of) your project folder(s) and modify it there. Don't forget to add it to your project!
Thanks, I'll try! And will standard printf reference to my new putchar? Not for putchar from C166\LIB\?
will standard printf reference to my new putchar? Yes, it will.