Why is it that I have to set TI from software before I can get my printf() to execute ?
I seems printf() busy waits in TI ?
Why is this so ?
Is not TI supposed to be set by the hardware ?
It's really very simple ...
With the code that printf uses, a loop is entered that waits for the TI bit to be set. When the condition is met, the bit is then cleared and a character written to SBUF.
The TI bit is normally set when a character has been fully transmitted; but, after a reset, the TI bit is clear and would normally remain so until a character has been transmitted.
So to get things kicked off - The code could write the first character to the UART without waiting for the TI bit to be set.
But this might require some extra logic in the code to determine 'is this the first or subsequent character'.
It is far simpler to emulate the complete transmission of the first character by setting the TI flag - Then the code simply assumes that what is required for the first and subsequent character is the same.
Hope this helps.