I can't receive from ESP8266

Viewed 33

I am using ESP8266 with STM32F103. The ESP receives the AT-command correctly and executes it, and I can receive the echo characters, but when it comes to the ESP response I can't receive anything.

Here is a pic to demonstrate the issue: https://drive.google.com/file/d/19Of8ENNDDB0YAV5H5HuamcWF_OwV8JSj/view?usp=sharing

For instance: I send ATE0 to stop the echo, the ESP executes the command and there is no echo anymore, but I can't receive "OK" or "WIFI CONNECTED" or any other response.

I have tried putty and it worked without any problems in sending or receiving, so the ESP is fine.

I am using 115200 Baud rate, and this is my code:

main:

void main(void)
{
    /* Init RCC */
    RCC_voidInitSysClock();
    /* Enable Clock For GPIOA & UART1 */
    RCC_voidEnableClock(RCC_APB2,GPIOA_BUS);
    RCC_voidEnableClock(RCC_APB2,14);

    /* Set TX and Rx Directions */
    MGPIO_voidSetPinDirection(GPIOA, PIN9 ,OUTPUT_SPEED_2MHZ_AFPP); /* TX */
    MGPIO_voidSetPinDirection(GPIOA, PIN10 ,INPUT_FLOATING);        /* RX */

    /* Set Direction For Pin 0 To power Led */

    MGPIO_voidSetPinDirection(GPIOA, PIN0 ,OUTPUT_SPEED_10MHZ_PP);

    /* Enable UART1 Interrupt */
    MNVIC_voidEnableInterrupt(USART1_ID);
    /* Init UART1 */
    MUART_voidInit();
    /* Init ESP */
    HESP_voidInit();
    /* Connect To WIFI Network */
    HESP_voidConnecttoWifi("Androidap","111112222");

    //HESP_voidConnectToServerTCP("162.253.155.226","80");

    //HESP_u8ReceiveResponse("Abdullaharm.freevar.com/status.txt","47");
    while(1)
    {

    }
}

Implementation of ESP_init and connect to WIFI functions:

void HESP_voidInit(void)
{
    //MUART_voidTransmitSynch("AT\r\n");

    /* Stop Echo */
    MUART_voidTransmitSynch("ATE0\r\n");
    /* Set Station Mode */
    MUART_voidTransmitSynch("AT+CWMODE=1\r\n");

    MSYSTICK_voidSetBusyWait(1000);//microseconds
}

void HESP_voidConnecttoWifi(uint8* Copy_u8SSID , uint8* Copy_u8Pass)
{
    /* Connect to WIFI network */
    MUART_voidTransmitSynch("AT+CWJAP_CUR=\"");
    MUART_voidTransmitSynch(Copy_u8SSID);
    MUART_voidTransmitSynch("\",\"");
    MUART_voidTransmitSynch(Copy_u8Pass);
    MUART_voidTransmitSynch("\"\r\n");
} 

Implementaion of UART_TransmitSynch:

void MUART_voidTransmitSynch(uint8 arr[])
{
    uint8 i=0;
    while(arr[i] != '\0')
    {
        UART1 -> DR = arr[i];
        /* wait till transmission is complete */
        while (!(UART1->SR & (1<<6)));

        i++;
        MSYSTICK_voidSetBusyWait(2000); //microseconds
    }
}

I am using interrupt to receive from the ESP and this is the code inside ISR:

void USART1_IRQHandler(void)
{
    if(GET_BIT(UART1 -> SR , 5))
    {
        static uint8 Data_Counter=0;
        if(UART1 -> DR !='\0')
        {
            Data_Received_int[Data_Counter]=UART1 -> DR;
            Data_Counter++;
        }
        else
        {
            Data_Counter=0;
        }
        CLR_BIT(UART1 -> SR , 5);
    }
    //UART_CallBackPtr();
}
0 Answers
Related