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/CC2642R: UART callback mode not working

Part Number: CC2642R

Tool/software: TI-RTOS

Hi,

I have peripherals connected to both UARTs on my design. The problem I'm facing is that the UART interrupt is never triggered even though the UART RX/TX lines are receiving/sending the data (I've confirmed with a scope). The function initializing any UART is below:

void SimplePeripheral_uartOpen() {
    UART_Params_init(&uart_params);
    uart_params.readMode = UART_MODE_CALLBACK;
    uart_params.readCallback = read_uart_cb;
    uart_params.readDataMode = UART_DATA_BINARY;
    uart_params.readReturnMode = UART_RETURN_FULL;
    uart_params.readEcho = UART_ECHO_OFF;
    uart_params.baudRate = 115200;
    uart_params.stopBits = UART_STOP_ONE;
    uart_params.parityType = UART_PAR_NONE;
    uart_params.dataLength = UART_LEN_8;

    uart = UART_open(CC26X2R1_MYDEVICE_UART0, &uart_params);

    //memset(uart_buf, 0, sizeof(uint8_t) * BUF_SZ);

    if (uart == NULL) {
        //send error here
        uart_error = 1;
        return;
    }
    UART_control(uart, UARTCC26XX_RETURN_PARTIAL_ENABLE, NULL);
}

"read_uart_cb" is never called unless I keep polling UART_read() on an infinite loop. How could I get read_uart_cb called using interrupts instead of inefficient polling?

I'm using SimplePeripheral example project and  simplelink_cc26x2_sdk_2_20_00_36 SDK version. I'm also using Code Composer.

Thank you.

  • I would recommend updating to the latest version of the SDK.  Also, can you update the code snippet to try and perform the blocking version found here

    and then move to the callback use case also described:

    static void taskFxn(uintptr_t a0, uintptr_t a1)
    {
        UART_Handle handle;
        UART_Params params;
        // Init UART
        UART_init();
        // Specify non-default parameters
        UART_Params_init(&params);
        params.baudRate      = 9600;
        params.writeMode     = UART_MODE_CALLBACK;
        params.writeDataMode = UART_DATA_BINARY;
        params.writeCallback = writeCallback;
        params.readMode      = UART_MODE_CALLBACK;
        params.readDataMode  = UART_DATA_BINARY;
        params.readCallback  = readCallback;
        // Open the UART and initiate the first read
        handle = UART_open(Board_UART, &params);
        wantedRxBytes = 16;
        int rxBytes = UART_read(handle, rxBuf, wantedRxBytes);
        while(true); // Wait forever
    }

    Regards,

    Chris

  • Hi Chris,

    Thanks for your response. There are some issues for me to do what you suggested:
    1. The newer SDK does not work with the SoC Rev I have. I have Rev C of CC2642R1 and it does not support the latest SDK for Rev E.
    2. The Wait forever can't happen 'cause I have other stuff going on on that Task. Are you suggesting for me to create a second Task and add to the system? Do you have a reference code I could take a look in order to implement that?

    Thank you,

    Anderson
  • Apologies for the confusion. I have learned that the revision C will not be supported, please upgrade your system to the revision E silicon as described here.

    e2e.ti.com/.../767774

    Regards,
    Chris