-->
Page 1 of 1

UART on GPIO5 and GPIO4 at baud 115200

PostPosted: Tue Aug 25, 2015 11:21 pm
by zain.mir
I need an additional uart link on my esp8266 to communicate with an arduino at baud rate 115200 using the additional GPIOs. A quick google search only revealed a softuart library on git [https://github.com/plieningerweb/esp8266-software-uart], which I tested and it works but not for a 115200 baud rate. If it is possible, a point in the right direction would be much appreciated. Thanks.

Re: UART on GPIO5 and GPIO4 at baud 115200

PostPosted: Tue Sep 08, 2015 9:23 am
by eriksl
The esp8266 has two UARTS, but none of them can be multiplexed to GPIO4 and GPIO5.

There is a document that states which pin can be multiplexed to what function, I'd suggest you read that first ;)

Re: UART on GPIO5 and GPIO4 at baud 115200

PostPosted: Tue Sep 08, 2015 11:36 am
by dkinzer
zain.mir wrote: softuart library [...] works but not for a 115200 baud rate.
At 115.2K baud the bit time is 8.68uS. That's only 694 CPU cycles at 80MHz. I've operated my SW UART code at 115.2K transmiting but reception is dicey at best at that speed. Lower baud rates are more likely to work because there is more "room" to allow for system NMI servicing, system call overhead, etc.

You might be able to get the code you referred to to work if you change the CPU speed to 160MHz. You might also be able to modify the referenced code so that it is more efficient. Some possibilities:
    o Strip it down to support a single SW UART.
    o Change pin I/O to support only the two pins you want thus eliminating the table lookup.
    o Read the RTC Timer2 register directly rather than calling system_get_time(). I haven't looked at system_get_time() to see how much overhead it adds.
    o Eliminate RS485 support and everthing else you don't need.
If none of that works and you still insist on using 115.2K baud you'll probably have to add an external UART chip.

Re: UART on GPIO5 and GPIO4 at baud 115200

PostPosted: Tue Sep 08, 2015 12:41 pm
by eriksl
Or use the second UART. You may have to change the flash I/O into DIO or even single lane I/O, because the second UART probably uses the same pins as the flash I/O.