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.

TMS570LC4357: sciReceive api use for input of different length

Part Number: TMS570LC4357

I want to use sciReceive api for reception of data with different length each time.
 

void sciReceive(sciBASE_t *sci, uint32 length, uint8 * data)

example : 

1st time if I want to receive data : abc (3 byte length)

2nd time if i want to receive data : qwerty (5 byte)


What if the data length on my serial port is different each time?

  • Hello,

    1. You can define the communication protocol between two UART devices. Before sending the real data ( 2bytes, 3 bytes or ...), the device sends the length first.

    2. You can add time-out code to sciReceive() function. 

        time_out = 0;

        while (length > 0U)  // you can use a big value for length for example length=100; or you can change the loop as while(1)
        {

                 time_out++:


                 /*SAFETYMCUSW 28 D MR:NA <APPROVED> "Potentially infinite loop found - Hardware Status check for execution sequence" */
                while ((sci->FLR & (uint32)SCI_RX_INT) == 0U)
                {

                      if (time_out > xxx)

                          break or return
                } /* Wait */

                /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
               *data = (uint8)(sci->RD & 0x000000FFU);
               

                /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
                /*SAFETYMCUSW 567 S MR:17.1,17.4 <APPROVED> "Pointer increment needed" */
                data++;
                length--;
          }

  •  how to send different data length each time 

    example : on SCI3 port  I want to receive the input data of different length.

    How timer will help to skip length precondiion to receive data using void sciReceive(sciBASE_t *sci, uint32 length, uint8 * data).

    I don't want to use length as highlighted in above image, as I will send data of different length each time.

    Is it possible ?

  • It depends on how you send data to TMS570 device. 

    You can use time-out if you know the longest interval between each char.

    You can send a special char to tell the receiver this is the last char.