I download intsio.zip and only changed some word in main.c as following:
void main (void) { com_initialize (); /* initialize interrupt driven serial I/O */ com_baudrate (38400); /* setup for 38400 baud */ printf ("Interrupt-driver Serial I/O Example\r\n\r\n"); while (1) { unsigned char c,cCmd,cCmdLen,i; c = getchar(); if (c == 0xaa) { c = getchar(); if (c == 0x55) { c = getchar(); if (c == '@') { c = getchar(); cCmd = c; c = getchar(); if ((c+cCmd) == 0xff) { cCmdLen = getchar(); for ( i = 0 ; i < cCmdLen ; i ++) { c = getchar(); printf("%c" ,c); } } } } } } }
What processor are you using, and what clock speed? Where are your ring buffers - xdata? data? or what? Are you sure that your system has sufficient performance to guarantee that you will never miss a character?
Processor:P89LV51RD2 Clock:11.0592MHz Buffer:xdata(p89lv51rd2 ram_on_chip's xdata is 768 bytes,and xdata used 517bytes) Platform:\win2000\program\addition\communication\supperClient When baudrate been changed to 9600 or 4800,the same thing happened. sio.c never been changed,and main loop just shew as up. Best regards, Nantiangumo
Additionally,just doubly transmit and never miss bytes. Thanks.
It seems like you expect getchar() to echo the received character. (If not, the command prefix AA 55 40 etc would not appear.) In the command body, you also echo characters with printf(). (I'd suggest putchar() for less overhead.) This would cause the characters to be echoed of the command body to be output twice, once by getchar and once by printf. Is your serial output buffered, or at least synchronized with a delay loop watching TI? What if printf() writes to the SBUF before the byte written by the getchar() character has finished transmitting? Since both routines are writing the same value, you might see only one appear. I don't understand why the prefix to the command should ever be doubly echoed. You say this is correct, but I wouldn't expect that from the posted code. Only the bytes after the command length should be doubled.
"It seems like you expect getchar() to echo the received character." Yes, that is the documented behaviour of the standard Keil C51 implementation: http://www.keil.com/support/man/docs/c51/c51_getchar.htm
"Buffer: xdata (p89lv51rd2 ram_on_chip's xdata is 768 bytes, and xdata used 517bytes)" So your ring buffers are in XDATA. What size are they?