This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problems working with timers and serial ports simultaneously

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) {}
	}
This code worked perfectly and the receiving was still done by the interrupt function with no problems.
This wouldn't present itself as a serious problem because if i tried to receive or transmit once again everything would work, but i started to use timer 0 for another part of my program. The first time I transmited the timer interrupt would stop responding because TI1=1. The only way i can force TI1 to zero is by disabling the serial port (with ES1), disable TI1 and re-enable the serial port.
The problem is I don't understand very well how the program works, and what i've been doing wrong, because the function i programmed looks like the opposite of the example program provided by keil...

0