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 / CC2650:CC2650 uart 1byte callback

Part Number: CC2650

Tool/software: TI-RTOS

How can I receive a callback in 1 byte with the TI-RTOS UART driver?

Thank you

  • Hi Shouehi,

    A basic example of this is available in the UART API documentation (or inside the UARTCC26XX.h header file).

    #define MAX_NUM_RX_BYTES    1000   // Maximum RX bytes to receive in one go
    uint32_t wantedRxBytes;            // Number of bytes received so far
    uint8_t rxBuf[MAX_NUM_RX_BYTES];   // Receive buffer
    
    // Callback function
    static void readCallback(UART_Handle handle, void *rxBuf, size_t size)
    {
        // Process data
    }
    
    static void taskFxn(UArg a0, UArg a1)
    {
        UART_Handle handle;
        UART_Params params;
        // Init UART and specify non-default parameters
        UART_Params_init(&params);
        params.baudRate      = 9600;
        params.writeDataMode = UART_DATA_BINARY;
        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 = 1;
        int rxBytes = UART_read(handle, rxBuf, wantedRxBytes);
        while(true); // Wait forever
    }

  • Thank you
    I have read UART_read many times.
    It seems I was wrong.

    Err

    void read_uart(UART_Handle hndle, void *buf, size_t count)
    {
        is_callback = true;
    
    }
    
    void read(void)
    {
        char input;
        while (1)
        {
            UART_read(uart, &input, 1);
            if (is_callback)
            {
                UART_write(uart, &input, 1);
                is_callback = false;
            }
        }
    }

    OK
    void read_uart(UART_Handle hndle, void *buf, size_t count)
    {
        is_callback = true;
    }
    
    void read(void)
    {
        char input;
        UART_read(uart, &input, 1);
    
        while (1)
        {  
            if (is_callback)
            {
                UART_write(uart, &input, 1);
                UART_read(uart, &input, 1);
                is_callback = false;
            }
        }
    }
    

  • I'm not sure I understood your last post, are you having some problems?

  • I am always grateful for your help.
    The above source is an error.
    The source below was ok.
  • Ah ok!

    Good luck with the future development!