qq_42001557 2019-04-23 18:07 采纳率: 0%
浏览 668

esp8266模块执行不了stc8单片机发送的at指令

stc8单片机串口2与esp8266连接 我给模块发at指令的字符串 模块闪了蓝灯,应该是发送到了 但是模块并没有执行想要的at指令,求救

#include "stc8.h"
#include "intrins.h"

#define FOSC            11059200UL
#define BRT             (65536 - FOSC / 115200 / 4)
sbit LED1=P5^5;

bit busy;
char wptr;
char rptr;
char buffer[16];

void Uart2Isr() interrupt 8 using 1
{
    if (S2CON & 0x02)
    {
        S2CON &= ~0x02;
        busy = 0;
    }
    if (S2CON & 0x01)
    {
        S2CON &= ~0x01;
        buffer[wptr++] = S2BUF;
        wptr &= 0x0f;
    }
}

void Uart2Init()
{
    S2CON = 0x50;
    T2L = BRT;
    T2H = BRT >> 8;
    AUXR = 0x14;
    wptr = 0x00;
    rptr = 0x00;
    busy = 0;
}

void Uart2Send(char dat)
{
    while (busy);
    busy = 1;
    S2BUF = dat;
}

void Uart2SendStr(char *p)
{
    while (*p)
    {
        Uart2Send(*p++);
    }
}
void delay(unsigned int m)        //????
    {
      int  a=0,b=0;
      for(a=0;a<500;a++)
      for(b=0;b<m;b++);

    }
void main()
{
    Uart2Init();
    IE2 = 0x01;
    EA = 1;
      delay(2000);
    Uart2SendStr("AT+CWMODE=2");
      Uart2Send('\r');
      Uart2Send('\n');
      LED1=0;
      delay(5000);
    Uart2SendStr("AT+CWSAP=\"521\",\"123465789\",1,4");
        Uart2Send('\r');
      Uart2Send('\n');
      delay(5000);
      Uart2SendStr("AT+RST");
        Uart2Send('\r');
      Uart2Send('\n');
    while (1)
    {
              LED1=1;

    }
}
  • 写回答

1条回答 默认 最新

  • unsigned1 2020-03-15 22:47
    关注

    你的WiFi的波特率跟串口的波特率是一致的吗,一般默认是115200

    评论

报告相同问题?

悬赏问题

  • ¥15 Excel发现不可读取的内容
  • ¥15 UE5#if WITH_EDITOR导致打包的功能不可用
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面
  • ¥15 算法题:数的划分,用记忆化DFS做WA求调
  • ¥15 chatglm-6b应用到django项目中,模型加载失败
  • ¥15 CreateBitmapFromWicBitmap内存释放问题。