I am using Infineon XC866 and Keil uvision. I selected the LX51 Linker in the project setup. The UART is init through
/// Initialization of module 'UART (Serial Interface)' UART_vInit();
// USER CODE BEGIN (MAIN_General,10) void message( char *pucMessage ) { // while the character is not 0 while (*pucMessage) { SBUF = *pucMessage++; while (TI == 0) {;} TI = 0; } return; } // USER CODE END
And for putchar ? Do I also need to set TI=1 first. Do you need to set TI=1 before every printf and putchar ?
No, putchar is called from printf. In principle the printf works like your function. The TI is set to enable transmitting of character. Thats all. The printf() is implemented to take care about that. After each character that was transmitted the TI will reset to 0 and for the next character again to 1. For the first character you must set the TI to '1' yourself. Stefan
You should also rearrange your message() function as follows: while (*pucMessage) { while (TI == 0) {;} TI = 0; SBUF = *pucMessage++; } otherwise it will prevent putchar() from working.