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.

CCS/LAUNCHXL-F28379D: String Loopback

Part Number: LAUNCHXL-F28379D


Tool/software: Code Composer Studio

Hi,

I wanna do a string loopback with F28379D. There is an example code wherein we do a string write and char read. 

for (;;)
{
msg = "\r\nEnter a character: \0";
SCI_writeCharArray(SCIB_BASE, (uint16_t*) msg, strlen(msg));

//
// Read a character from the FIFO.
//
receivedChar = SCI_readCharArray(SCIB_BASE, (unit16_t*)receivedChar, 100)  //

//Now Here i wanna do a string read insted of char.  I am adding below statement

//receivedChar = SCI_readCharArray(SCIB_BASE, (unit16_t*)receivedChar, 100);

//the syntax is :void SCI_readCharArray ( uint32_t base, uint16_t const array, uint16_t length ) Now PLease tell me how to do it. Also If we don't know the size ofstring to be received, then How to define the size?

//
// Echo back the character.
//
msg = " You sent: \0";
SCI_writeCharArray(SCIB_BASE, (uint16_t*) msg, strlen(msg));
SCI_writeCharArray(SCIB_BASE, (uint16_t*) receivedChar, strlen(receivedChar));

//
// Increment the loop count variable.
//
loopCounter++;
}

  • hi Vishal,

    receivedChar = SCI_readCharArray(SCIB_BASE, (unit16_t*)receivedChar, 100);

    The syntax above is fine . It expects that you will wait for a certain number of characters / string ( here 100) which is read and stored in the array (receivedChar).

    If the size or number of characters is not clear then there we can look to using method like :

    • wait for a magic character like '\0' and then exit from the loop when that character is received . This will need the API SCI_readCharArray to be tweeked since currently the for loop would only break after the expected  number of characters is received. 
    • cancel the data receive after a timeout of some time

    Maybe a useful thread for some inputs:

    https://e2e.ti.com/support/microcontrollers/c2000/f/171/p/820254/3043585

    Regards.