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

printf serial port 8051

Hi. Why does TI need to be set before printf is called.

TI = 1;
printf("Hello world\n");


Whereas in assembly TI should be cleared before a char is put in SBUF, so it can be tested to see if the char has been sent

Parents
  • "Why does TI need to be set before printf is called"

    It is nothing specifically to do with printf - it's a "feature" of the default putchar implementation provided by Keil.

    If you don't like the way that the default putchar implementation provided by Keil works, you are completely free to provide your own implementation!

    The instructions to do that are provided in the documentation for printf.

    "in assembly TI should be cleared before a char is put in SBUF, so it can be tested to see if the char has been sent"

    Again, that's nothing specifically to do with assembler - that's just the way you've chosen to implement it in your assembler.

    There is nothing to stop you making a similar implementation in 'C'...

Reply
  • "Why does TI need to be set before printf is called"

    It is nothing specifically to do with printf - it's a "feature" of the default putchar implementation provided by Keil.

    If you don't like the way that the default putchar implementation provided by Keil works, you are completely free to provide your own implementation!

    The instructions to do that are provided in the documentation for printf.

    "in assembly TI should be cleared before a char is put in SBUF, so it can be tested to see if the char has been sent"

    Again, that's nothing specifically to do with assembler - that's just the way you've chosen to implement it in your assembler.

    There is nothing to stop you making a similar implementation in 'C'...

Children