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) {} }
Hi Ric, It is look like the time is not enough to do both JOB. Say you set serial intterrupt at 19.2Kbit/s then every 520uS the serial interrupt will come(10 bits), insight the ISR you will take may be 500uS, so you only have 12uS, if you set yoour timer interrupt 50uS then you have a problem, and insigth the timer ISR you may spend more time. You can check this by setting one pin to high when you are enterring ISR then low when you leave ISR
Well, actually I did have such problems, but i found out that enabling the high priority on both serial ports solved it... And if sometimes i miss the timer 0 interrupt it's not that important... The thing i don't understand is how i can transmit by using the function i posted earlier... I set the TI1 to 0 and that's the contraray of the example given by keil.
Hi, The idea behid received and tranmit using serial interrupt is 1. Receiving data sould be at the correct time other wise you will miss some data, So it should be activated when you received 1 byte or if you use FIFO the data should remove once it reach water mark of the FIFO 2. But transmit data is not like that, you can prepare the transmit buffer or fill your transmit fifo then you can call this function to transmit, what Keil is expalin is while you are filling the data into your transmit buffer you cannot enable tranmit interrupt.
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