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/CC2650: UART failed to open successfully

Part Number: CC2650

Tool/software: Code Composer Studio

Hi,

I am using CC2650 launchpad with contiki-ng and the platform in which I am working on is Simplelink.

I want to use uart for that I am referring to the UART.h library which is located at ti/drivers in simplelink architecture folder in Contiki-ng.

Here is my code 

#include "contiki.h"
#include <ti/drivers/UART.h>
/*---------------------------------------------------------------------------*/
PROCESS(cp, "GPIO Project");
AUTOSTART_PROCESSES(&cp);
PROCESS_THREAD(cp, ev, data)
{
    PROCESS_BEGIN();
    char        input;
    UART_Handle uart;
    UART_Params uartParams;

    // Initialize the UART driver.
    UART_init();

    // Create a UART with data processing off.
    UART_Params_init(&uartParams);
    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readDataMode = UART_DATA_BINARY;
    uartParams.readReturnMode = UART_RETURN_FULL;
    uartParams.readEcho = UART_ECHO_OFF;
    uartParams.baudRate = 115200;

    // Open an instance of the UART drivers
    uart = UART_open(Board_UART0, &uartParams);

    if (uart == NULL) {
        // UART_open() failed
        printf("Failed");
    }
    else {

    // Loop forever echoing
    while (1) {
        UART_read(uart, &input, 1);
        UART_write(uart, &input, 1);
    }
    }
    PROCESS_END();
}
/*---------------------------------------------------------------------------*/

This code is not working as the UART_open function returning some errors.

Regards,

Pranav

  • UART is enable by default in contiki so you don't have to init it again. You can refer to Contiki UART usage in sunmaysky.blogspot.com/.../using-contiki-udp-client-to-send-onoff.html
  • Part Number: CC2650

    Hey,

    I am using contiki-ng for the development of my project on launchpad cc2650 and the target platform is simplelink.

    I want to use the uart for my project and or that I am using the UART.h library which is located under ti/drives in contiki architecture folder for simplelink.

    it is failing to open the uart.

    Now I think that there is only one uart and the printf function is using that to pass the serial messages to the terminal.

    If this is the case then it is possible to use the uart for some other purpose alogside with printf.

    or there is a way to disable use of uart by printf and assigning the uart exclusively for particular purpose

    #include "contiki.h"
    #include <ti/drivers/UART.h>
    /*---------------------------------------------------------------------------*/
    PROCESS(cp, "GPIO Project");
    AUTOSTART_PROCESSES(&cp);
    PROCESS_THREAD(cp, ev, data)
    {
        PROCESS_BEGIN();
        char        input;
        UART_Handle uart;
        UART_Params uartParams;
    
        // Initialize the UART driver.
        UART_init();
    
        // Create a UART with data processing off.
        UART_Params_init(&uartParams);
        uartParams.writeDataMode = UART_DATA_BINARY;
        uartParams.readDataMode = UART_DATA_BINARY;
        uartParams.readReturnMode = UART_RETURN_FULL;
        uartParams.readEcho = UART_ECHO_OFF;
        uartParams.baudRate = 115200;
    
        // Open an instance of the UART drivers
        uart = UART_open(Board_UART0, &uartParams);
    
        if (uart == NULL) {
            // UART_open() failed
            printf("Failed");
        }
        else {
    
        // Loop forever echoing
        while (1) {
            UART_read(uart, &input, 1);
            UART_write(uart, &input, 1);
        }
        }
        PROCESS_END();
    }
    /*---------------------------------------------------------------------------*/
    

    Regards,

    Pranav

  • I have tried to help you in your another duplicate post.

  • The UART0 peripheral is by default initalized by the Contiki-NG runtime. Simple include the "uart0-arch.h" header and use the api in your code.