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.

LAUNCHXL-F280025C: SCI Tx Blocking mode, wait for TimeOut

Part Number: LAUNCHXL-F280025C

Hi,

I would like to send a string as blocking mode which is make sure all characters are sent, what I did   : 

1. make sure no Tx interrupt  //SCI_setFIFOInterruptLevel(SCIA_BASE, SCI_FIFO_TX2, SCI_FIFO_RX16);

2. after SCI_writeCharArray, add SCI_isSpaceAvailableNonFIFO to check is all characters are sent. 

without TIMEOUT option, I am afraid it may trapped forever, is any other good method to achieve it ? 

memset(name, 0x00, 20);

sprintf((char *)name, "TI-SCI-A");

TxCount = sprintf((char *)TxBuffer, "AT+NAME%s\r\n", charDeviceName);

SCI_writeCharArray(SCIA_BASE, (uint16_t*)TxBuffer,TxCount);

while(!SCI_isSpaceAvailableNonFIFO(SCIA_BASE)) {;}

void initSCIAFIFO()

{

    // 8 char bits, 1 stop bit, no parity. Baud rate is 9600.

    SCI_setConfig(SCIA_BASE, DEVICE_LSPCLK_FREQ, 9600, (SCI_CONFIG_WLEN_8 | SCI_CONFIG_STOP_ONE | SCI_CONFIG_PAR_NONE));

    SCI_enableModule(SCIA_BASE);

    SCI_resetChannels(SCIA_BASE);

    SCI_enableFIFO(SCIA_BASE);

    // Interrupts Enabled only RX

    SCI_enableInterrupt(SCIA_BASE, SCI_INT_RXFF);

    SCI_disableInterrupt(SCIA_BASE, SCI_INT_RXERR);

 

    // disable tx interrupt ? 

    //SCI_setFIFOInterruptLevel(SCIA_BASE, SCI_FIFO_TX2, SCI_FIFO_RX16);

    SCI_setFIFOInterruptLevel(SCIA_BASE, SCI_FIFO_TX16, SCI_FIFO_RX1);

    SCI_performSoftwareReset(SCIA_BASE);

    SCI_resetTxFIFO(SCIA_BASE);

    SCI_resetRxFIFO(SCIA_BASE);

}

  • Hi,

    The subject matter expert is out of office (US holiday) and will get back ASAP. Please expect delay in response.

     

    Thanks,

    Saravanan

  • Hi Danny,

    Thanks for your question.

    without TIMEOUT option, I am afraid it may trapped forever, is any other good method to achieve it ? 

    Here are a two ways to achieve this without a built-in timeout method, by creating your own:

    1. Use a CPU Timer or EPWM timer as part of the for loop (check for both SCI_isSpaceAvailableNonFIFO AND if the timer is done)

    2. Use a counter in the while loop and exit after a certain number of counts. This may be less desirable as it is less time-based and more iteration based.

    Regards,

    Vince