the code below is transmit and receive an array data serial. the array data is to be transmitted back in the reverse order. HTerm is used in place of hyperTerminal #include <reg51.h> #include <stdio.h>
bit flag = 0; unsigned char c[10],s, count = 0; void send_serial(unsigned char *s);
void main() { SCON = 0x52; TMOD = 0x20; TH1 = 0xFD; TR1 = 1; EA = 1; ES = 1; if(flag) { for(s = count - 1; s > 0; s--) { SBUF = c[s]; while(!TI); TI = 0; } } }
void ser_intr(void)interrupt 4 {
c[count]=SBUF; IE=0x00; count++; if(c==0x0d) { flag = 1; } RI=0; IE=0x90; }
I didn't see any question in your post.
But you have a number of issues you need to consider.
Besides the lack of comments and the use of magic constants - have you spent any time testing your code with good and bad input data?
/pwm