Hi teams:
I am recently doing modbus communication between two devices. I would like to ask, as a slave, how should I handle it when the data received exceeds the UARTFIFO SIZE?
I set up a receiving array in the UART receiving interrupt to receive data.
Before configuring the UARTFIFO, I used the serial port debugging assistant to send data with a frame length of 11 bytes. Each time the array could only receive the first 8 bytes. data, the last three data will be lost.
-------The reason is that UARTFIFO is in "UART_FIFO_RX4_8" mode by default, that is, an interrupt is triggered every 8 bytes, so the host sends 11 bytes, the first 8 bytes are received, and the last three bytes cannot be received because the interrupt is not triggered. arrive
So there are two directions to solve this problem.
One is to adjust the FIFO depth and set the UARTFIFO to "UART_FIFO_RX7_8" mode, that is, triggering an interrupt to receive up to 14 bytes, then the 11 bytes I sent can definitely be received completely at one time.But if the data I send exceeds 14 bytes, will the data be lost as before?
The second solution is to refer to the following link and set the FIFO to the minimum length, that is, two bytes trigger an interrupt. However, I debugged and found that if I sent 11 bytes of data, I would receive 5 interrupts, and Not 6 times, this will still cause data loss,So setting the FIFO to 2, 4, 8, 12, 14 bytes, the data I send each time must be an integer multiple of them?
Link: e2e.ti.com/.../tms320f280039c-q1-uart-rxfifo-uart-received-is-more-than-rxfifo-size
My problem is summarized as follows:
(1) There are 5 modes in UARTFIFO level setting, UART_FIFO_RX1_8, UART_FIFO_RX2_8, UART_FIFO_RX4_8, UART_FIFO_RX6_8, UART_FIFO_RX7_8. If it is set to UART_FIFO_RX1_8 mode, TM4C1290NCZAD UARTFIFO Size is 16*8bit. The meaning of setting this mode is every 2 bytes. , trigger a receive interrupt? If the host sends 11 bytes of data and is configured in this mode, does it need to trigger 5 or 6 interrupts? When I set the UARFIFO mode to UART_FIFO_RX7_8, if according to the above understanding, a receive interrupt is triggered every 14 bytes, why can an interrupt be triggered when I receive 11 bytes?
(2)If the data sent exceeds UARTFIFO SIZE, how can we receive this frame of data completely?
(3)How to configure TM4C to receive a byte as an interrupt?Although this takes up a lot of resources, in this way, no matter what data is sent, it can be received completely.
I hope that an expert can patiently answer my questions. If you have any questions, please send me a private message in time. Thank you very much.