CC2340R2: UART read function issue

Part Number: CC2340R2
Other Parts Discussed in Thread: SYSCONFIG

Tool/software:

I am currently working with the CC2340 BLE module and using the basic_ble example from the SDK. As part of the development, I am testing UART communication, I expect the device to send a response when data is received from Docklight.

In the existing example, UART is configured as a display uart(CONFIG_DISPLAY_UART). I’m unable to find a suitable UART read function in the code. And I also reviewed the uart_echo example in the SDK and attempted a similar implementation within the basic_bleproject. when I try to open the UART using UART2_open(), it fails to initialize. Could you please help us resolve this issue?

Pin_Configuration:

TX - DIO20
RX - DIO22

  • Hi !

    When printing text, the software has to chose a UART instance it wants to use. In the case of the basic_ble project, the menu module used by the example opens a display driver instance with the setting "Display_Type_ANY", which will use the first display device it finds.
      

    In your case, the first display device will be your first UART device in SysConfig.

    If you want to chose what display you want to use, you will need to open a display driver instance yourself and use the handle to this instance to call the UART write functions. You can find the guide and API on how to do this in this link.

    In short, your code will look like this :

    // Import the UART2 driver definitions
    #include <ti/drivers/UART2.h>
    
    // Open the UART
    UART2_Handle uart;
    // Depends on your SysConfig names
    uart_0 = UART2_open(CONFIG_UART2_0, UART2_config[CONFIG_UART2_0]);
    
    // Write to the UART
    int16_t BUFSIZE = 2;
    int32_t status;
    uint8_t buffer[BUFSIZE];
    size_t  bytesRead;
    status = UART2_read(uart_0, buffer, BUFSIZE, &bytesRead);
    
    // Close the UART
    UART2_close(uart_0);

    You can setup your UART device in SysConfig. If you have issues with how to use this code, please reply here.

    Kind regards,
    Maxence