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.