用的是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;
}
|