When program running to "printf()",the PC always stop at
C:0X0A2A 3099FD JNB TI(0X98.1),C:0A2A
ES = 0; //UART INT is Enable before TI = 1; printf("%bd",3); ES = 1;
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
Thanks Jon. The puchar() routine doesn't be changed ,I just write a UART INTTERUPT routine for receiving the data from Decode_Card and enable UART Interrupt in Initial().When debugged in UV3,the program output nothing without
ES = 0; TI = 1
The program outputs nothing because the interrupt is getting triggered each time TI is set. You can't mix polled and interrupt-driven serial I/O on an 8051. Jon
Catch your words,if enable UART-Interrupt then can't use printf() to poll flag's bit .Can you give me some example about sending data from 8051 with UART Interrupt routine? Thanks.
View all questions in Keil forum