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: TMS570LC4357 Serial Communication Data Drift

Part Number: TMS570LC4357

Hi everyone,

I am studying on getting data from peripheral device by using SCI3 and keep the received (hexadecimal) data in an array (byte array with the size of 8); however, each element of the array shifts. I couldn't resolved the source the problem, what is the reason of this shift?

Best Regards

  • Hi,

    If it is a user defined array in the program then i don't think it can automatically shifts the data unless we write an algorithm to shift the data. 
    Can you share your code?
    And can you please also tell me how you are testing?

    --

    Thanks,

    Jagadish.

  • Hi,

    I just use sciReceive code to get data by using basically the example (https://www.youtube.com/watch?v=PpalANwuzIo), and save the received data in an empty array.

    Since this is a private task, I cannot share the code. Could you help me if there is any option like direct message to share code?

    Regards,

  • Hi Kardelen,

    I followed video shared by you and i just configured same as in video, i don't see any problem at my end.

    I just created one array to store 10 characters from SCI.

    After that i just called "sci_receive" and i initialized my array to it and i also mentioned length as 10. So that i will get a notification interrupt after i received 10 characters from SCI.

    I am setting one flag in notification function to indicate my receive operation completed. And in my while(1) loop, i am just verifying that flag to perform some action.

    I tested and it worked as per my requirement. You can just try this project on your end.

    570LC_UART_NEW.zip

    --

    Thanks,

    Jagadish.

  • Hi Jagadish,

    Your code is a little bit different from the example I shared previously. However when I adapted your code to mine, I cannot receive data. All elements of array seems as 0. 

    Regards,

  • Hi Kardelen,

    My code is not different, i configured same as the video you shared. 

    The things i changed in the code is to solve your requirement. I created one array for receiving data and i pass that array to receive function with required length i.e.10 in this case.

    The thing i dont understand is, are you giving data from terminal?

    You have to check your device manager and should configure same port in terminal window of CCS

    I am sharing my debug video, please have a look

    If you look at that video, before debugging start my "rx_data" buffer is empty. And i configured my terminal with XDS port showing in device manager. After that i run the code and i got a message that "Please send data:" in the terminal. After that i type "a to j" letters(10 characters) in terminal that i received same data in my debug window of "rx_data" buffer.

    8032.570LC_UART_NEW.zip

    There is no changes from previous code except i added one line to send a "Please send data:" to the terminal. 

    --

    Thanks,

    Jagadish.

  • Hi Jagadish,

    I applied your code to mine and I see that data does not shift. However, after revision the data in the received  array is not updated when I change element values of sent data ( hexadecimal array).

    By the way, I don't use terminal to see received data, I just check values of array elements in debug mode (as you did in your video) and I read data from another device.

    Question 2: I don't understand how sciNotification works. In the video (https://www.youtube.com/watch?v=PpalANwuzIo), they use sciReceive 2 times: Firstly, in main loop; secondly, in sciNotification block. As well as I know, sciNotification is  an interrupt and it occurs for each received element. Then why it wasn't used just in sciNotification block. Could you please explain this issue more clearly?

    Regards.

  • Hi,

    ->I applied your code to mine and I see that data does not shift.
    Data will never shift in the "rx_data" buffer we are passing.

    If you verify above handler code which is present in the "lin1HighLevelInterrupt" function. Whenever controller SCI receives a new character, the processor executes the "lin1HighLevelInterrupt" function and particularly it comes to the case 11 as shown above. Here the received new character will be moved to the buffer pointer i.e. g_sciTransfer_t[0U].rx_data and after that rx length is decrementing by one and buffer pointer will be incremented by one to point new empty location in the buffer we passed, if rx length is not equal to zero then it will exit from this function and repeats the same process for next character as well. If rx length becomes zero means we received configured number of characters so in that case it will calls the sciNotification function.

    Note: 

    The function "lin1HighLevelInterrupt" is calling because we are giving the same function name in VIM(Vector Interrupt Module) table, this is nothing but a loading function offset address into the vector table.

    also please note that we enabled only RX_INT

    So whenever a new RX_INT will get trigger and it calls the "lin1HighLevelInterrupt" function, and there it will read the interrupt status "sciREG1->INTVECT0" based on status it will execute the corresponding case.

    --

    Thanks,
    Jagadish.

  • Hi Jagadish,

    Firstly, thank you for your explanation, this issue is more clear to me now. But still I couldn't understand why received data array is not updated when I change one of the elements in the sent data (array). I do the same things with you, but I face such kind of problem. Could you please help me to resolve this issue?

    Regards.

  • Hi,

    Basically in SCI we have two lines, one for transmission and other for reception

    There won't be any cross connection between Tx and Rx until we forcefully short Tx and Rx externally(i.e. loop back). Both will work independently.

    If you write any data on sent data(array) and given to "sciSend" function then the data will transmit on Tx line of SCI.
    Similarly if we call the receive buffer with the "sciReceive" function, then any data from externa device over rx line will be moved receive buffer.

    In our testing we connected Terminal window in the place of external device for simulation purpose

    So when we call "sciSend" function with send buffer array then the data in the send buffer array will be moved to terminal window from controller over Tx line and after receiving data the terminal window will display the data.

    Similarly when we type any data on terminal window, it received to Receive buffer over Rx line from terminal to controller.

    I hope it clarifies your doubts.

    --

    Thanks,

    Jagadish.

  • Hi,

    I think we are not talking about the same issue. Let me explain more clearly, I just receive data from another processor. When sent command changed, I cannot see the change on received data array (on expressions section) while debugging. I stop debugging and redebug the code, then I can see the change. My question is why I stop debugging to see changes because in application I shouldn't stop process to receive updated data (I must see the changes simultaneously).On the other hand, we don't use terminal because we would like to make sure about communication problems such as shifting, updating.

    Regards.

  • Hi,

    Sorry i missed your last comment, as the case is in "waiting for customer" status.

    Are you still facing issues?

    --

    Thanks,
    Jagadish.

  • Hi,

    Yes, I still have the same problem.

    Best regards.

  • Hi,

    Can you please explain issue again?

    --

    Thanks,
    Jagadish.

  •  Sure,  I receive data from another processor. When sent message (which is sent to TMS570LC4357) is changed, I cannot see the change on received data array (on expressions section) while debugging. I stop debugging and redebug the code again, then I can see the change. My question is why I stop debugging to get the changed received message package because in application I shouldn't stop process to receive updated data (I must see the changes simultaneously).

    On the other hand, we don't prefer using terminal (just check expressions while debugging) because we would like to make sure about communication problems such as shifting, updating.

  • HI,

    I guess it is because of you are calling SCI receive function only one time. If you call it one time only then it will stop after required number of bytes received.

    Try to call it again, after receiving of first array to receive second array.

    After you received length number of bytes into array for the first time again call this function with same array and required number of bytes, then your array will update with new data.

    --

    Thanks,

    Jagadish.