ESP8266 RTOS SDK version 1.4.0 "how to get data from UART0?"

serkam
Posts: 11
Joined: Thu Nov 03, 2016 9:52 pm
Location: Sao Paulo, Brazil
Contact:

ESP8266 RTOS SDK version 1.4.0 "how to get data from UART0?"

Postby serkam » Fri Nov 18, 2016 8:47 pm

Hi

I need to build a UART console routine ( as a thread ) for my ESP8266 project under RTOS SDK ( 1.4.0 ), for debugging purposes, but, I couldn't use scanf or getchar to get data from UART0. The program is compiled and linked without problem, but, at execution, the FreeRTOS enter in a crazy loop. The console routine is built as a thread. If I comment the block code with scanf or getchar, the thread works perfectly, indicating that the problem is over scanf or getchar.

Which function can I use instead scanf or getchar?

Any example available, please?

Thanks

Sergio

pratik

Re: ESP8266 RTOS SDK version 1.4.0 "how to get data from UART0?"

Postby pratik » Sat Nov 19, 2016 1:51 pm

Did you look up the UART APIs in RTOS SDK API Reference PDF?
You can simply register an interrupt handler and process the keystrokes in there. That would be the best way to work with UART. Meanwhile I can try to come up with some examples for the same.

Also, see the function definitions in uart.h header file... they are described in the header file itself and you can use the character receive function from there!

serkam
Posts: 11
Joined: Thu Nov 03, 2016 9:52 pm
Location: Sao Paulo, Brazil
Contact:

Re: ESP8266 RTOS SDK version 1.4.0 "how to get data from UART0?"

Postby serkam » Tue Nov 22, 2016 5:21 am

Hi Pratik

Thanks you for your directions.

I solved my problem, without using interrupt:

if( (READ_PERI_REG(UART_STATUS(0))>>UART_RXFIFO_CNT_S) & UART_RXFIFO_CNT )
{
data = READ_PERI_REG(UART_FIFO(0) );
}

As my console is a thread and the data flux is low ( few console commands ), polling method works very well.

Problem solved.

Anyway, thank you for your kind support.

Sergio

pratik

Re: ESP8266 RTOS SDK version 1.4.0 "how to get data from UART0?"

Postby pratik » Fri Nov 25, 2016 1:23 pm

Thanks for taking the time to post your solution. This is simple and useful for low transfer rates! :)

Who is online

Users browsing this forum: No registered users and 58 guests