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 statement not working after putchar statement is used.

Hi All
I am using following putchar routine.

void srl_putchar(unsigned char send)
{
SBUF = send;
while (!TI);
TI = 0;
}

after using above routine to transfer a character via serial port i continued with
 
printf("%c%c",dle,etx); 
but program control remained infinitely in printf().
So i want to know,
What is the problem with srl_putchar() routine ?
Thanks in advance!

Parents
  • Your putchar does things in a different order than the putchar that printf uses.

    The Keil putchar does things in this order.

    while (!TI);
    TI = 0;
    SBUF = c;
    

    It's pretty easy to see why printf stops working after srl_putchar is called.

    Why don't you use the putchar that's already provided?

    Jon

Reply
  • Your putchar does things in a different order than the putchar that printf uses.

    The Keil putchar does things in this order.

    while (!TI);
    TI = 0;
    SBUF = c;
    

    It's pretty easy to see why printf stops working after srl_putchar is called.

    Why don't you use the putchar that's already provided?

    Jon

Children