I required the usage of serial port 1 on a Dallas 89C420. In order to use it i checked the example program Interrupt-Driven Serial I/O Support for printf filename "intsio.zip". The example was adapted to my needs but all initializations were maintained as well as the core of the interrupt function. The problem was that TI1 never went back to 0 and if i tried to force it outside the interrupt keil would crash (i use serial port 0 for the debugger). And if i did nothing the program just transmitted forever. I changed the program and started to transmit outside the interrupt with the following code:
int counter; for (counter=0;counter<msg_size;counter++) { TI1=0; SBUF1=msg[counter]; while (TI1==0) {} }
The second think, Once you put some data into your tx buffer it will start to send, once it is sending you cannot put another data that is why the while loop is there, I beleived this will help you to understand