Part Number: LAUNCHXL-CC2650
Other Parts Discussed in Thread: TEST2, CC2650
Tool/software: TI-RTOS
I am developing code which I want to use to communicate throught UART. Now I have been testing and setting different parameters for the UART config, and writing the UART is no problem at all. But whenever I want to read the RX buffer with UART_read or UART_readpolling, the task gets stuck and ends somewhere waiting forever. When I declare a timeout in the readTimeout uartParam, it does seem to continue running the code when it has reached its timeout, but the data has not been read.
I have been searching for quite a while and could not find an answer to this problem. There was one person with a similar problem who posted on this forum, but solved it by running the example uart_echo code from TI-RTOS. Sad to say, this example gives the same results as my own written code which I based on the uart example.
These are my parameters:
void qbInitUART()
{
UART_Params uartParams;
//const char echoPrompt[] = "\fInitializing UART:\r\n";
/* Create a UART with data processing off. */
UART_Params_init(&uartParams);
uartParams.readTimeout = 100;
uartParams.writeTimeout = 100;
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 19230;
uart = UART_open(Board_UART0, &uartParams);
if (uart == NULL) {
System_abort("Error opening the UART");
}
//UART_write(uart, echoPrompt, sizeof(echoPrompt));
}
static void UART_taskFxn(UArg arg0, UArg arg1)
{
// Initialize the task parameters
UART_task_Init();
for (;;) {
//Random chars for testing
static uint8_t test[] = "1";
static uint8_t test2[] = "0";
UART_write(uart, &test, sizeof(test));
UART_read(uart, &test2, sizeof(test2));
memcpy(test, test2, sizeof(test2));
Task_sleep(sleepTickCount);
}
}
The IOID pins 2 and 3 are connected to eachother, and the board files also seem to correctly initialize these pins as UART pins. I use the test2 variable to detect whether the data is correctly read from the UART_write() of the variable test. If it results in continuously writing the ASCII "1", then it means that the reading succeeded.
The UART_init(); is called in the main.c file and the parameters is called when I initialize the task. I have been looking at this for quite a while, and am using a logic analyzer to verfiy the sent data, but it always resulted in "0" instead of continuously "1". I can't figure out what I am doing wrong right now.