Sign In

Trouble In Receveing The Respones Of Esp8266

morteza kheyri Iran, Islamic Republic of

Hardware: Pic18f4550 Running In 8mhz And 9600 Baudrate On Breadboard Software: C Project Using Mplab X Ide And Peripheral Libraries To Pic18f

i try to receive the responses of esp 8266 to my AT commands to show them in my 2*16 character lcd.
in mp lab i use the( void getsUSART(char *buffer, unsigned char len) )command to receive the Rx and save it to buffer but this function needs the length of received data and i dont know i can know the length of Rx data.



R Avinash
2016-06-16 06:57:38
The function of peripheral library are very basic.

You need to implement a interrupt driven data reception mechanism with a FIFO queue.

The MCU to jumps to the ISR (interrupt service routine) when a byte is received from usart. It puts them in a queue (just like we stand in a queue) the end of the queue is where ISR puts data. And the first person in the queue is which MCU will read first. MCU can also query how many bytes are waiting in queue.

Have you put a 8MHz crystal on it? How have you configured the CONFIG bits? I mean the PLL and the clock sources? This is very important to write timing sensetive code like that of USART.

Show me picture of your setup and the configuration bits settings.
R morteza kheyri
2016-06-16 13:44:13
hi.and thank you for your reply.
i dont have a crystal and i use internal 8Mhz oscilator with OSCCON=0x76;
the config bits are OK and i send data to esp8266 properly and just i have trouble in receveing data.
usart is configured such as:
R Avinash
2016-06-17 03:46:18
post your complete program ...
R Avinash
2016-06-21 12:09:50
waiting for your response ...
R morteza kheyri
2016-06-21 18:37:29
sorry for my delay in your respone replying:
i wrote a uart interrupt and i could to receive respones.
but sometimes occur a wrong in char receveing.
this wrong is occured in proteus and yet i don't do it in practical programming.
when i write "asdf" the string in virtual terminal (as the response of module) that printed on lcd is right and "asdf" is printed.
but when i write "aaaaaaaa" the string that printed in lcd is "acaaaaac".
the uart Rx interrupt program is.
void interrupt getData(void)
            if(PIR1bits.RCIF == 1)
                    rx = getcUSART(); //read the byte from rx register
                    if (rx=='r')
                    //PIR1bits.RCIF = 0; // clear rx flag
R Avinash Gupta
2016-06-22 04:29:29
This may be due to wrong baud rate generator settings.
R morteza kheyri
2016-06-22 13:59:11
i check the baud rate settings and the receiver and tranceiver's baud rate is same and is 9600 .

Post a reply to morteza kheyri

Think you can help morteza kheyri ? Then post your thoughts that might help morteza kheyri. You will earn a lot of reputation in the technical community.

If your program is in multiple files, then ZIP the entire folder and attach below

Images and Screenshots

These helps other better understand your suggestion.