Home > Back-end >  Sprout new. 51 single-chip microcomputer serial string flashbacks
Sprout new. 51 single-chip microcomputer serial string flashbacks

Time:11-05

#include
#include
#include
# define unsigned char
Char [] s={0};//send a temporary variable

Int dx (char [] s)
{if (s==NULL) return 0;
Char c;
Int len=strlen (s), I=0;
While (i{c=s [I]; S=s [I] [len - I - 1); S [len - I - 1]=c; i++;
}
Printf (" % s \ n ", s);
Return s;
}
Void UART_init ()
{
TMOD=0 x20;//T1 work mode 2 8 automatic reinstall
TH1=0 XFD;
TL1=0 XFD;//bitrate 9600
TR1=1;//start the timer T1
SM0=0;
The SM1=1;//serial works 1 REN=1;//serial port allows the receiving
EA=1;//always interrupt
ES=1;//open serial port interrupt
}
Void main ()
{
UART_init ();//serial port initialization
Dx ();
While (1);
4} void UART interrupt ()
{
If (RI)//check whether receive complete
[I] {s=SBUF;//num out the value of the receive buffer RI=0;//software reset flag bit TI=1; If (TI); {TI=0; SBUF=s [I];
}
}
}
  • Related