# include "reg52. H"//this file defines the MCU some special function register
# include "intrins. H"//this file defines the MCU some special function register
Typedef unsigned int under-16;//to statement defines the data type
typedef unsigned char u8;
Sbit led=P2 ^ 0;
U8 a=0;
U8 receive [2].
Void delay1ms (under-16 I)//0 error us
{
Unsigned char a, b, c;
For (c=I; C> 0; C -)
For (b=142; B> 0; B -)
For (a=2; a> 0; A -);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* the function name: UsartInit ()
* function function: set up a serial port
* input: no
No
* output:* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Void UsartInit ()
{
SCON=0 x50;//set to work 1
TMOD=0 x20;//set the counter works 2
PCON=0 x80;//double baud rate
TH1=0 xf3; Initial value is set//counter 4800
TL1=0 xf3;
ES=1;//open the serial port interrupt
EA=1;//open the total interruption
TR1=1;//open the counter
}
Void the send (u8 n)//character send
{
ES=0;//close the serial port interrupt
SBUF=n;//send data
while(! TI);//waiting to send complete
TI=0;//remove sent interrupt request marks a
ES=1;//open the serial port interrupt
}
Void ESP8266 u8 * (s)//MCU send ESP8266 AT configuration instructions,
{
While (* s!='\ 0')
{
Send (* s);//one by one to send
S++;
}
S=0;
}
Void main ()
{
Led=0;
UsartInit ();//serial port initialization
ESP8266 (" AT + CIPMUX=1 \ r \ n ");
Delay1ms (1000);
ESP8266 (" AT + CIPSERVER=1606 1 \ r \ n ");
Delay1ms (1000);
While (1);
}
Void Usart interrupt ()
4{
The receive [0]=SBUF;
RI=0;//remove receiving interrupt flag bit
SBUF=receive [0];//send the received data into the register
while(! TI);//wait for sending data complete
TI=0;
}
CodePudding user response:
Are you someone who helpCodePudding user response:
If need to feed the dog! Delay is too long!CodePudding user response:
Capital, capital, capital bCodePudding user response:
You this serial assistant can also check MCU send data and data from 8266 to send?