I am currently making something that needs the UART to be working interrupt/event driven. I am using the timeout ("RX_TOUT") interrupt to signal that the fifo can be read and fifo empty ("TXFIFO_EMPTY"). I set a threshold for the tout interrupt, I enable the tout interrupt, the fifo interrupt is enabled whenever there is data to be sent and then disabled.
All works, so I must be doing something right.
The problem is that if I send data to the uart quickly, only the first 126 bytes can be fetched. It doesn't matter what baudrate is used, so it's not a "too slow" issue. Apparently the fifo's are 128 bytes, so it probably has to do with that. But I don't understand. For the reception of data from uart I think it works like this:
1 receive fifo is empty
2 first byte of some data is received and put into the receive fifo
3 if fifo is not empty for "timeout threshold" time, generate timeout interrupt
4 goto 1
1 timeout interrupt triggered, callback is called
2 callback reads ALL data from the fifo until it's empty again
3 interrupt is cleared and interrupt is enabled again
I don't understand why the fifo apparently isn't completely emptied in time by my software. Apparently the fifo gets overrun. The callback should be called after just a few bytes in the fifo, that should be plenty of time to fetch all bytes from the fifo.
Maybe I don't understand the #defines correctly:
- UART_RX_TOUT_EN: enable receive fifo "timeout", if fifo is not empty for "threshold" uart byte times, raise an interrupt so the fifo can be emptied
- UART_RX_TOUT_THRHD: the threshold; I've used 2, 32, 64 and 120, it doesn't matter
- UART_RXFIFO_TOUT_INT_ENA: enable the interrupt
- UART_RXFIFO_FULL_THRHD: the threshold for the fifo being "full", there is no "ENABLE" function for this?
- UART_RXFIFO_FULL_INT_ENA: enable the interrupt (I am not using this)
What is exactly meant with the "threshold" values? For the "timeout", does it mean, smaller value is interrupt quicker (after lesser bytes) or the other way around? For the "full" threshold, is it actually used when the interrupt is not enabled? If so, what is it's meaning, is it used to the set the actual fifo size?
Last but not least, why is there no include file with the register definitions in the sdk?
Who is online
Users browsing this forum: No registered users and 2 guests
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
We also have a RTOS version and a MESH version too!
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!