Correct, that's why I said you need to decide if you should keep the interrupt enabled or disable it when you are in the ISR. You need a way to figure out if the character just loaded into the TX-reg was the last character to send or not. You can have an end of line character, fixed length or you need to have a variable indicating the location of the last character in the circular buffer.This can be very tricky and lead to an endless loop of interrupts in case you do not have to send something for a while.
You can also do it in software. Have a DataToSend flag which you set when there's data to send. The main routine checks this flag each iteration, if set AND there's room in TX-reg you GOSUB your transmit routine. The transmit routine loads one character from the buffer into the TX-reg, checks if all data is sent, if it is it resets the DataToSend flag if not it leaves it set. Then it returns to the main routine.
This aproach works OK as long as you don't have a lot of pause statements or other commands which "hangs" the MCU in which case the serial output will slow down - which might or might not matter.
Out of curiosity Ioannis, did you end up in that endless loop or what happend?
/Henrik.
Bookmarks