Some matter with my "printf()",what can i do ?

When program running to "printf()",the PC always stop at

C:0X0A2A 3099FD JNB TI(0X98.1),C:0A2A
I try adding some word as following :
ES = 0;   //UART INT is Enable before
TI = 1;
printf("%bd",3);
ES = 1;

So , the program running well.Can you tell why being disable UARTs'INT and Setting TI are necessary? How can i overleap this word ?

Another question,why "printf("%bd",3);" can send unsigned char variable to PC right while "printf("%c",3);" not ? What's different between %bd and %c?

Parents
  • C:0X0A2A 3099FD JNB TI(0X98.1),C:0A2A

    This instruction waits for the TI bit to get set. You need to read-up on that this bit is used for. You need to set it the first time but it is set by hardware thereafter.

    Can you tell why being disable UARTs'INT and Setting TI are necessary?

    The printf function calls putchar to send a byte. By default, the putchar routine uses a polled scheme to send characters. Did you write your own putchar for the interrupt?

    What's different between %bd and %c?

    A lot. %bd sends a number encoded in ASCII. %c sends the ASCII character. So, "%bd", 3 transmits the ASCII character 51 while "%c",3 transmits the ASCII character 3.

    Jon

Reply
  • C:0X0A2A 3099FD JNB TI(0X98.1),C:0A2A

    This instruction waits for the TI bit to get set. You need to read-up on that this bit is used for. You need to set it the first time but it is set by hardware thereafter.

    Can you tell why being disable UARTs'INT and Setting TI are necessary?

    The printf function calls putchar to send a byte. By default, the putchar routine uses a polled scheme to send characters. Did you write your own putchar for the interrupt?

    What's different between %bd and %c?

    A lot. %bd sends a number encoded in ASCII. %c sends the ASCII character. So, "%bd", 3 transmits the ASCII character 51 while "%c",3 transmits the ASCII character 3.

    Jon

Children
More questions in this forum