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/CC2652RB: CC2652RB

Part Number: CC2652RB

Tool/software: Code Composer Studio

Hi all,

  I am running the project zero on the dev board and I have problems with the UART RX INT

 

 

here is the setup

on init:

    UART_init();

    // Initialize UART parameters
    UART_Params_init(&Bottom_COM_Params);
    Bottom_COM_Params.baudRate = c_Top_Baudrate;
    Bottom_COM_Params.readMode = UART_MODE_CALLBACK;        //UART_MODE_BLOCKING
    Bottom_COM_Params.writeMode = UART_MODE_CALLBACK;
    Bottom_COM_Params.readTimeout = UART_WAIT_FOREVER;        //UART_WAIT_FOREVER;
    Bottom_COM_Params.writeTimeout = UART_WAIT_FOREVER;
    Bottom_COM_Params.writeCallback = Send_Byte;
    Bottom_COM_Params.readCallback = Byte_Received;
    Bottom_COM_Params.readDataMode = UART_DATA_BINARY;
    Bottom_COM_Params.writeDataMode = UART_DATA_BINARY;
    Bottom_COM_Params.readReturnMode = UART_RETURN_FULL;

    // Open the UART

    Bottom_COM_Handle = UART_open(BOTTOM_UART, &Bottom_COM_Params);

   pRX = &RX_Buffer[0];
    Bytes_Received = 1;
    UART_read(Bottom_COM_Handle, pRX, Bytes_Received);

in the RX Call back a timeout timer is started, which sets a flag indicating Data was received

void RXTimeout(UArg ID){
    Timeout_ON = false;
    RX_Received = true;
}


void Byte_Received(UART_Handle handl, void *buf, size_t count){
    // Set and Start COM Timeout Timer
    if(Timeout_ON == false){
        Util_startClock((Clock_Struct *)TimeOutHandle);
        Timeout_ON = true;
    }
}

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

this setup works perfectly for the TX INT, I put one Byte in the X buffer, it gets transmitted and in the TX int it gets the next byte.... and so on.

 

problem with RX INT

setting the

    Bytes_Received   to 0 does not set the INT, the call back function Byte_Received() gets never called!

-------

    Bytes_Received   to 1 set the INT, the call back function Byte_Received() gets called!

but when it comes to   

            ReceivedFromUART = UART_read(Bottom_COM_Handle, pRX, i);

the first byte is missing?!!! and ReceivedFromUART is always 0!!! but there are all the bytes in the pRX[] buffer, except the first one

 

Is this a bug in the UARTCC26XX.c file?

I don't understand why the RX INT is only set with UARTCC26XX_read(xxx);

 

thanks for your help

Best regards

Kurt

 

 

 

 

  • Hi Kurtlin,

    It is not clear why you expect you setting Bytes_Received  would invoke the interrupt or callback, maybeyou could elaborate on this?

    As for the return value of UART_read(), in callback mode, the default return value is 0. The actual number of bytes received you get via the read callback.

  • Hi M-W

       sorry was a bit of a misunderstanding, the Byte_Received() does not invoke the INT it just enables it.

    I am under the impression, if a byte is received the call back function (set with .readCallback) is called. 

    As

    Warning Do not call UART_read() from its own callback function when in UART_MODE_CALLBACK.

    I set a flag in the callback function to notify the main loop. In the main loop I do a read of the bytes received.

    As mentioned in my post before, I have to call the UART_Read() function to enable the INT (size has to be at least 1!), if that function is not called the buffer gets never filled with the incoming data!

    Anny additional calls to UART_Read() messes up the buffer - the received bytes are in there, but the order is messed up (looks like a circular buffer).. 

    Thanks for your help

    best regards

    Kurt

     

     

  • Hi Kurt,

    You should be able to call UART_read from inside the callback as long as you consider what it could result in (for example nested callbacks). From the first call of UART_read until you explicitly cancel it (or there is a frame error), the RX module will be left on. This means that the UART hardware keeps receiving in the background. The driver has an internal ring buffer where it stores the received data between UART_read calls. In the case where you only read out one byte at a time you could very well be wrapping this buffer if you are receiving faster than you read out.

    I would typically recommend doing larger reads than "1" and instead enable the "Return partial" behavior of the driver (this page also contains an "continuous RX example): 

    https://dev.ti.com/tirex/explore/content/simplelink_cc13x2_26x2_sdk_4_20_00_35/docs/tidrivers/doxygen/html/_u_a_r_t_c_c26_x_x_8h.html