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.

UART_read() continuous reading with callback function

Other Parts Discussed in Thread: CC1310

I am using a CC1310 with TI-RTOS 2.15.0.17

From the documentation under Receive Continously in UART_MODE_CALLBACK the last part of the callback function is:

    // Start another read, with size the same as it was during first call to
    // UART_read()
    UART_read(handle, rxBuf, wantedRxBytes);

The documentation for UART_read() states:

Warning
It is STRONGLY discouraged to call UART_read from its own callback function (UART_MODE_CALLBACK).

 

So which is correct, the warning or the example that contradicts it? If the sample is wrong, how should continuous reading be implemented for event driven communications?

  • Matthew,

    I think the first text about starting another read (coming from UARTCC26XX.h) is incorrect.  I will ask around tomorrow and get back to you…

    Regards,
    Scott

  • Matt,

    The documentation here specifically applies to UARTCC26XX.h. For this driver, UART_read() calls within the callback does not have the chance for a task/system stack overflow. As far as I know, this is not encouraged for all other UART driver implementations (MSP43x, Tiva, etc...) in TI-RTOS.
  • For clarification on this issue, using UART_MODE_CALLBACK on the CC13xx/26xx it appears that your callback indeed MUST run UART_read() to keep the process going - or else all RX and Interrupts are disabled:

    /*
     *  ======== UARTCC26XX_swiIntFxn ========
     *  Swi function that processes UART interrupts.
     *  @param  arg         The UART_Handle for this Hwi.
     */
    void UARTCC26XX_swiIntFxn(UArg arg0, UArg arg1)
    {
        UARTCC26XX_Object               *object;
        UARTCC26XX_HWAttrsV1 const     *hwAttrs;
    
        /* Get the pointer to the object and hwAttrs */
        object = ((UART_Handle)arg0)->object;
        hwAttrs = ((UART_Handle)arg0)->hwAttrs;
    
        /*       Release power constraint. */
        threadSafeStdbyDisRelease(&uartRxPowerConstraint);
    
        /*       Disable RX interrupts */
        UARTIntDisable(hwAttrs->baseAddr, UART_INT_OE | UART_INT_BE
                       | UART_INT_PE | UART_INT_FE | UART_INT_RT |
                       UART_INT_RX);
    
        /* Reset the read buffer so we can pass it back */
        object->readBuf = (unsigned char *)object->readBuf - object->readCount;
    
        /* Do Callback */
        object->readCallback((UART_Handle)arg0, object->readBuf,
                             object->readCount);
    
        Log_print2(Diags_USER1, "UART:(%p) Read finished, %d bytes read",
                   hwAttrs->baseAddr, object->readCount);
    }

    Does this sound right?  Also I noticed that UART_read() will disable RX interrupts when completed in UART_MODE_BLOCKING, making UART_MODE_CALLBACK by far the most reasonable approach for handling nonstop streaming data (e.g. from a GPS, my current project...)

  • Hi Eric,
    We generally discourage posting a new question to an old closed thread because the person who answered before may no longer be available, and also it will allow whomever is currently assigned to monitor the forum to respond to you more quickly. For these reasons, I suggest you start a new thread with your question and reference this thread.

    Thank you