This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
I am trying to send a message from an application to the F28377 via SCI. The message has a header with a message ID and message body size. The body size would tell the software how many more char to expect from the serial port. I can not seem to come up with a good way to know when to stop reading from the serial port and start another message. The original idea was to use a FIFO interrupt to wait on 4 char representing the header since that is guaranteed and then read the rest of the data based on the size received. But the FIFO depth is only 16 and the message body can be larger than that so it loses data.
Does anyone have a common way to receive a large message over SCI? I have gone through all the TI examples to try and put together a solution. I tried polling on the receipt of characters on serial interface.
BOOL read_serial_message ( UINT16 *msg_id, /* OUT: The ID of the message. */ UINT16 *msg_size, /* OUT: The size of the message body in bytes. */ INT8 *msg_buffer /* OUT: Pointer to hold the body of the message. */ ) { /* Read the id */ read_comm(test_comm, (INT8 *)tp_rx_msg_buffer, 2); *msg_id = (tp_rx_msg_buffer[0] << 8) | tp_rx_msg_buffer[1]; read_comm(test_comm, (INT8 *)tp_rx_msg_buffer, 2); *msg_size = (tp_rx_msg_buffer[0] << 8) | tp_rx_msg_buffer[1]; /* read the message */ read_comm(test_comm, (INT8 *)tp_rx_msg_buffer, (UINT32)*msg_size); return TRUE; }
The read_comm function reads data from SCI in the following format:
INT32 sci_read ( UINT16 chan, INT16 *buffer, UINT32 size ) { UINT16 i = 0; UINT16 offset = SCI_CH_REGS(chan); volatile union SCIRXBUF_REG *buf = (union SCIRXBUF_REG *) (((UINT16 *)&SciaRegs) + offset + RXBUFF_OFFSET); volatile union SCIFFRX_REG *ffrx = (union SCIFFRX_REG *) (((UINT16 *)&SciaRegs) + SCI_CH_REGS(chan) + FFRX_OFFSET); while (i < size) { /* Wait for the receiver to be ready */ while (ffrx->bit.RXFFST != 1) {} buffer[i++] = buf->all; } return i; }
This does not seem to work however as it gets stuck and blocks while waiting first read of the serial port for the two char that make up message id. Ideally we would avoid doing this type of polling and use an interrupt, if possible, but it was the latest attempt to achieve the results we wanted.
Any help is appreciated.
Thanks,
Matt
Matt,
You should use the RXINT along with RXRDY flag and RXFFST to tell how many messages are in the RX FIFO, after the FIFO reaches a certain number of messages you can store them elsewhere. See this post 28335: Samll FIFO in SCI it is for another device, however both devices have a 16 deep RX FIFO. If you want to know more about the registers above please check in the TMS320F2837xS TRM or TMS320F2837xD TRM.
Best of Luck!
Cody