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.

RTOS/SIMPLELINK-MSP432-SDK: No function similar to UARTCharAvail present in TIVA driver library for MSP432

Part Number: SIMPLELINK-MSP432-SDK

Tool/software: TI-RTOS

Hi Team,

My earlier project was made using TIVA board. However, now we have moved to MSP432 launchpad and we are using the Simplelink SDK version.

I am using the RTOS concept and I am trying to find if there is any function similar to "UARTCharsAvail(uint32_tBase)" that is available in the TIVA driver library to check if any characters are been there in the receive FIFO for continuous UART operation?

Please let me know if not I have to find a work around.

Thank you in advance.

Vikram

  • Vikram,

     If I read your intent correctly, I think the UART_read() function may already do what you want.   This API uses the uartParams structure to define, among other things, a "read Return Mode" that will cause the read buffer to fill until the input stream hits a Newline.

    This behavior is illustrated in the MSP432P4111 OutOfBox demo program. Look at the uart_thread.c source file to see the following code snippet shown below. In this code, the UART_RETURN_NEWLINE read mode is used when setting up the uart_handle.  This sets up an ISR callback function which gets called whenever the input stream hits a newline.

    Let me know if this is the kind of functionality you were after.

    /* Define UART parameters*/
    UART_Params_init(&uartParams);
    uartParams.writeDataMode = UART_DATA_TEXT;
    uartParams.readDataMode = UART_DATA_TEXT;
    uartParams.readReturnMode = UART_RETURN_NEWLINE;
    uartParams.readEcho = UART_ECHO_OFF;
    uartParams.baudRate = 115200;

    uart_handle = UART_open(Board_UART0, &uartParams);

    if (uart_handle == NULL) {
    /* UART_open() failed */
    while (1);
    }

    while (1) {
    UART_read(uart_handle, &rxString, MAX_STR_LENGTH); //input = RXD byte

    ------------------------------

    Regards,

      Bob

  • Thank you Bob for your input.

    I will try this out and get back to you.

    Regards,

    Vikram 

  • Hi Bob,

    I tried to use the concept for the demo uart code but did not find any difference in the outcome so will it be possible for you to please explain what is the difference in using the UART_RETURN_NEWLINE v/s UART_RETURN_FULL;

    The source that I will be getting data from is a black box to me as we don't have access to it in terms of what sort of data will it be sending.

    The task is that there is a pulser which triggers through a watchdog event on MSP432 and starts sending data over its uart line to the MSP432. So we are not sure whether it sends a new line character everytime or not?

    Thank you

    Vikram

  • Vikram,
    Unless the device at the other end explicitly sens a Newline, you may not see one. The UART_RETURN_NEWLINE /FULL parameters determine when the given thread unblocks or returns. So either a newline or a buff-full condition unblocks the READ command in that thread.

    As I understand this, you have just 1 MSP432 device communicating with something else, and you are using an input pulse from that other device to trigger a watchdog timer on the MSP432 (exactly why you're using a watchdog instead of just allowing the external pulse to trigger an interrupt isn't clear). After this pulse, you are receiving a constant stream of data for some time and you want to ensure that you don't get a buffer overflow. Thus you are checking the buffer (originally using UARTCharsAvail(uint32_tBase)) periodically to process that data.

    Is that an accurate description of what you are trying to do? And if so, is there a reason you are not using the UART read command and allowing it to unblock/return when the given buffer is full? I would think that would perform the same operation described above.

    Regard,s
    Bob
  • Hi Bob,

    Thank you for your reply.

    Yes, I have just one MSP432 device that communicates with the other device (micro pulser) over the UART.  The concept of watchdog is not triggered by the other device instead the watchdog is triggered at a fixed time interval in MSP432 and post this watchdog triggered event, I turn on the other device and send some command in reply to which the other device starts sending stream of data for some time. 

    So I want to ensure I don't get the buffer overflow error and since, I have to use the ring buffer to constantly collect the data received I also don't want to miss out on the data received.

    I am using the UART_read command but the problem is at times, I still run into the buffer overflow error.

    So if there is a function similar to UARTCharsAvail, I can use that to verify after certain fixed data value if something else is left to be received or not.

    Thank you

    Vikram

  • Vikram,

      Determining the righ approach here will requre knowing a little about the incoming datastream, but here are a few things to consider:

    1. The UART driver APIs have the options  when opening/initiatlizing (UART_params_init() ) a UART instance

    • UART_DATA_TEXT- treats all device line endings a a newline
    • UART_RETURN_NEWLINE - causes UARTread() to return when seeing a newline instead of when buffer is full
    • You could use the 2 options above to minimize the chance you'll overrun your buffer

    2. You could alternately use UART_readPolling(), which won't return until it has read <size> number of bytes. How you use this and the size to set depends on your incoming data. Again, if <size> is much less than your buffer size, then you reduce the chance of overunning your buffer.

    Regards,

      Bob

  • Thank you Bob,

    Much appreciated on the 3 points you mentioned. I will try with Option 1 since I cannot use the UART_readPolling() function.
    Hope to get the best result.

    Regards,
    Vikram

**Attention** This is a public forum