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.

SIMPLELINK-CC2640R2-SDK: SIMPLELINK-CC2640R2-SDK UART

Part Number: SIMPLELINK-CC2640R2-SDK

Hi

Sorry for this silly question. I had configured UART in simple link observer file.

I am ble to transmit data but I can't enable receive interrupt.

I did the following things but reading your UART.h file

void uart_receive_interrupt(UART_Handle handle, void *buf, size_t count); // Function Prototype

// UART Setup


UART_init();
UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_TEXT;
uartParams.readReturnMode = UART_RETURN_NEWLINE;
uartParams.readEcho = UART_ECHO_ON;
uartParams.baudRate = 115200;
uartParams.readCallback = uart_receive_interrupt;
uartParams.readMode = UART_MODE_CALLBACK;
GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
uart = UART_open(Board_UART0, &uartParams);

if (uart == NULL) {
/* UART_open() failed */
GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
while (1);
}

void uart_receive_interrupt(UART_Handle handle, void *buf, size_t count) // function declaration.
{
GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
UART_write(uart,"test\r\n",6);
}

I had gone through your docs folder which contain the documents for UART and other drivers but it has some functions that are not defined in your UART.h file. I found it strange.

I need the suggestion of what setting I did wrong and what should be done.

I am using "REALTERM SOFTWARE" as serial terminal for getting and sending data over UART. (other parameters such as stop bit, parity check, baudrate are set as defined in UART initialization).

  • Hi Vaibhav,

    Are you using UART for display as well? (This is the default setting for the simple observer project.)
  • Hi Marie

    No, I had removed all the display functionality and line of code from the file. I am using UART only. My main purpose is to enable UART Rx interrupt for my project. For testing I am using TTL to USB converter and get all data to my LAPTOP on Serial Terminal. From terminal itself I am sending data to BLE MCU on RX pin. But UART RX Interrupt Callback function doesn't execute.

    Thanks
    Vaibhav Bansal
  • What if you try binary mode instead of text mode for read?
    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readDataMode = UART_DATA_TEXT;
  • Also, Since the user's callback may be called in the context of an ISR, the callback function must not make any RTOS blocking calls as you have done in uart_receive_interrupt(). Please refer to this old example (based on old sdk/device) for the general concept:
    e2e.ti.com/.../1437104

    You can also refer to UART callback mode in the NPI implementation in HostTest project as a reference. Specifically, the npi_tl.c & npi_tl_uart.c files.
  • Also refer to the UARTCC26XX.h File Reference, Not Supported Functionality section that states UART_DATA_TEXT is not supported:
    dev.ti.com/.../node

    There are good examples in that same doxygen documentation.
  • What if you try binary mode instead of text mode for read?
    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readDataMode = UART_DATA_TEXT;

    I tried but it didn't work as well.

  • Hi

    I made the changes as follows after reading those """ npi_tl.c & npi_tl_uart.c files.""""

    I had compare y settings with them and didn't found any much difference still I made changes. Please find the CODE below


    void initialize_uart(uint32_t baudrate)
    {
    const char echoPrompt[] = "UART_INITIALIZED,";

    UART_init();
    UART_Params_init(&uartParams);

    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readDataMode = UART_DATA_BINARY;
    uartParams.readReturnMode = UART_RETURN_NEWLINE;
    uartParams.readEcho = UART_ECHO_OFF;
    uartParams.baudRate = baudrate;
    uartParams.readCallback = uart_receive_interrupt;
    uartParams.readMode = UART_MODE_CALLBACK;
    GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);

    GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    uart = UART_open(Board_UART0, &uartParams);
    UART_control(uart, UARTCC26XX_CMD_RETURN_PARTIAL_ENABLE, NULL);
    if (uart == NULL) {
    /* UART_open() failed */
    GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
    while (1);
    }
    UART_write(uart, echoPrompt, 17);
    GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
    }

    void uart_receive_interrupt(UART_Handle handle, void *buf, size_t count)
    {
    ICall_CSState key;
    key = ICall_enterCriticalSection();

    GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
    UART_write(uart,"test\r\n",6);

    ICall_leaveCriticalSection(key);
    }

    But Still Interrupt Function not called when I send data on RX of UART0.

    Rest I had also gone through the question link you had provided but it doesn't much fruitful.

    *Note:- All these settings are done in simple observer.c file not in main.c file.

    Thanks
    Vaibhav
  • Please refer to UARTCC26XX.h in the doxygen documentation:
    dev.ti.com/.../node

    There is example code there you can refer to.