用的是keil5编写程序,烧录完hex文件之后。发现在串口调试助手上wifi模块可以正常使用接收信息(我设置的是ap模式),但是连接到单片机通电后,就只能连接网络,手机app无法输入ip地址和端口号来连接wifi模块,求助我的代码为什么不能成功让单片机配置
#include <REGX52.H>
#define uint unsigned int
#define uchar unsigned char
uchar Recive_table[15];
uint i;
void delay_ms(uint ms)
{
uchar i,j;
for(i=ms;i>0;i--)
for(j=120;j>0;j--);
}
void delay_us(uchar us)
{
while(us--);
}
void Usart_Init()
{
SCON=0x50;
TMOD=0x20;
TH1=0xFD;
TL1=TH1;
PCON=0;
ET1=0;
TR1=0;
ES=1;
EA=1;
}
void SENT_At(uchar *At_Comd)
{
ES=0;
while(*At_Comd!='\0')
{
SBUF = *At_Comd;
while(!TI);
TI = 0;
delay_us(5);
At_Comd++;
}
ES=1;
}
void WIFI_Init()
{
SENT_At("AT+CIPMUX=1\r\n");
delay_ms(1000);
SENT_At("AT+CIPSERVER=1,8080\r\n");
delay_ms(1000);
ES = 1;
}
void main()
{
Usart_Init();
WIFI_Init();
delay_ms(450);
while(1);
}
void Uart() interrupt 4
{
if(RI==1)
{
RI=0;
Recive_table[ i]=SBUF;
if(Recive_table[0]=='+')
{
i++;
}
else
{
i=0;
}
if(i>=10)
{
if((Recive_table[0]=='+')&&(Recive_table[1]=='I')&&(Recive_table[2]=='P')&&(Recive_table[3]=='D'))
{
if(Recive_table[9]=='0')
{
P2 = 0x81;
}
if(Recive_table[9]=='1')
{
P2 = 0x00;
}
}
i = 0;
}
}
else
TI = 0;
}
|