??? 12/03/04 13:46 Modified: 12/03/04 13:49 Read: times |
#82463 - misunderstand behaviour Responding to: ???'s previous message |
hi,
tmp = data2; TB8 = 0; // 9th bit = 0 TI = 1; /**** NEED TRANSMISSION HERE ****/ /* transmit data3 */ tmp = data3; TI = 1; /**** NEED TRANSMISSION HERE ****/ flag = 0; Seems you miss the point. Assume you have allowed serial and global interupt. After you load the temporal buffer and set TI flag then the serial ISR is executed. It clears TI and loads byte to be sent into SBUF. Then program leaves the ISR. What does happen then? Looking at your code I see that you load the new value into temp. buffer and set TI again. But transmission of the previous byte is still in progress (probably)! As result, the serial ISR is vectored again and it overloads SBUF before its content has been transmitted. But this is just a programmer error. In fact, here you have logical error which is much more important. The main idea if you use the serial interrupt is a buffer (ring-buffer or something like it). With ISR you should not use the same source variable for sending continious data stream. It is possible when you just polling TI flag; but avoid it with the serial interrupt utilized generally. Another problem is that after the transmission has been done, TI flag is set with hardware itself and the serial ISR is executed once again. So your ISR routine execution "as it is" will never be stoped - it will be called once and once and it will send contents of tmp. continiously. What I may suggest: if your application and its main loop are not time-sensitive then just use polling method. Disable the serial interript and send a byte after TI is set only. Do set TI once during initialization and do not set it in the rest of code because it is set by hardware after each byte has been sent. Otherwise, if your application requires all MCU productivity then use temporal buffer and ring-pointer (software FIFO). Regards, Oleg |
Topic | Author | Date |
THE TIME OF TI | 01/01/70 00:00 | |
Bitrate | 01/01/70 00:00 | |
interrupt-driven | 01/01/70 00:00 | |
Why interrupt driven? | 01/01/70 00:00 | |
UART Serial Port Interrupt | 01/01/70 00:00 | |
all the above | 01/01/70 00:00 | |
UART communication by UART interrupt | 01/01/70 00:00 | |
just TI=1 | 01/01/70 00:00 | |
serial interrupt in adc interrupt | 01/01/70 00:00 | |
start with something simple | 01/01/70 00:00 | |
misunderstand behaviour | 01/01/70 00:00 | |
See the examples | 01/01/70 00:00 | |
not has to, but can | 01/01/70 00:00 | |
The difference is | 01/01/70 00:00 | |
" | 01/01/70 00:00 | |
He's right | 01/01/70 00:00 | |
How the 8051 UART works | 01/01/70 00:00 | |
The TI-bit Set Time | 01/01/70 00:00 | |
no, at the middle | 01/01/70 00:00 | |
The Transmitter Part, Actually | 01/01/70 00:00 | |
Setting of TI | 01/01/70 00:00 | |
sometimes chip designers listen | 01/01/70 00:00 | |
So, Erik | 01/01/70 00:00 | |
where does it happen | 01/01/70 00:00 | |
Mode 1 TI timing. | 01/01/70 00:00 | |
How to post code | 01/01/70 00:00 | |
RS485 & bus turnaround![]() | 01/01/70 00:00 |