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.

CC1310: Read UART signal with Sensor and Collector example

Part Number: CC1310

Hi guys,

I am working with a sensor has UART output. I succeeded in reading its output with CC1310 and RXD jumper removed.

But when I combined this project to a big one like Sensor and Collector example, it did not work correctly.

I found out that the UART is being used for LCD_WRITE_STRING() function, so I want to close it whenever the readSensors() runs.

Here is the code that I programmed in readSensor() function:

LCD_WRITE_STRING("Start Reading",1);
UART_Params uartParams; // the TROUBLE starts here
UART_close(UART_open(Board_UART0, &uartParams));  //close UART of LCD_WRITE_STRING() first

UART_init();  //start new UART with params of sensor
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 9600;
UART_Params_init(&uartParams);

UART_read(UART_open(Board_UART0, &uartParams),&buffer, sizeof(buffer));  //open UART andread sensor signal and write into buffer
UART_close(UART_open(Board_UART0, &uartParams)); // close the UART again

UART_init(); // start new UART for LCD_WRITE_STRING()

uartParams.baudRate = 9600;

UART_Params_init(&uartParams);
UartPrintf_init(UART_open(Board_UART0, &uartParams)); // enable LCD_WRITE_STRING()
LCD_WRITE_STRING_VALUE("BUFFER: ", buffer[32], 10, 3); //print Buffer output

The result is not good when it is stuck at "State changed: 3". I tried to press BTN-2 and Reset to reset launchpad but it continue to loop between STATE 2 and STATE 4 forever.

I think that I did not close the UART correctly but I don't know how to fix it.

  • Hello Sang,

    Can you check to make sure that the the UART_Open is returning a Handle? also you should save the handle and use that handle instead of calling open every time.

    Regards,
    AB
  • Hi AB,
    I called uart = UART_open(uart = UART_open(Board_UART0, &uartParams); and checked if uart == NULL. It's stuck in a whlie loop, I think.
    Everything works until I add line UART_close(uart) to close UART of System_printf() in readSensors() function.
    Maybe the params I used in readSensors() is different from params in defined(BOARD_DISPLAY_USE_UART) in main function.
  • Hello,

    When you check for uart==NULL, is it true?

    When you try closing using the uart handle, does the readSensor() have access to the uart handle?

    Regards,
    AB
  • Hi AB,

    Fortunately, I have already done with reading UART output from the sensor.

    The reason that I stuck at while loop is I called the UART_Params and UART_Handle 2 times, the first time is in main.c file to activate LCD_WRITE_STRING(), the second is in sensor.c to active UART_read(). I should use only one params and handle to perform with UART.