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.

RTOS/LAUNCHXL-CC2650: Adding reading-over-UART task to Simple BLE peripheral doesn't work

Part Number: LAUNCHXL-CC2650
Other Parts Discussed in Thread: CC2650

Tool/software: TI-RTOS

I have a working modified version of the SimpleBLEperipheral project, that sends data over BLE to a peer device, once notifications are enabled.

I'm trying to add another task, that reads data over UART (from another cc2650, but right now I'm manually typing characters through Putty).

There's no logical dependency between the two tasks, one communicates over BLE and the other one just reads from UART.

Each of the two tasks run perfectly by itself, but when I create the two of them only the BLE task is working. 

Specifically, the execution gets to the Semaphore pend (see bellow), but the UART read callback function is never called.

At first, when I created the two tasks, none of them run, and when I increased the BLE task stack size it worked. But, this "trick" did not work for the UART task.

Any ideas on how to debug this? or what could be the reason for this behavior?

Following is the UART code.

Many thanks!

void UART_taskFxn(UArg arg0, UArg arg1)
{
	// Initialize application
	UART_task_init();

    UART_Params uartParams;
    measurement_t* meaPtr;

    /* 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.readMode = UART_MODE_CALLBACK;
    uartParams.readCallback = uartReadCallback;
    uartParams.readEcho = UART_ECHO_OFF;
    uartParams.baudRate = 115200;

    uart = UART_open(Board_UART0, &uartParams);
	UART_read(uart, &rxMsg, MEASURMENT_LEN_BYTES);

	while (1)
    {
		Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);
		while (!Queue_empty(measurementQueueHandle))
		{
			meaPtr = Queue_dequeue(measurementQueueHandle);
			free(meaPtr);
			// Need to add code here...
		}
    }
}


static void uartReadCallback(UART_Handle handle, void *buf, size_t count)
{
	measurement_t *measurmentPtr = (measurement_t *) malloc(sizeof(measurement_t));;
    strncpy(measurmentPtr->data, buf, count);
	Queue_enqueue(measurementQueueHandle, &measurmentPtr->_elem);
	Semaphore_post(semHandle);
	PIN_setOutputValue(ledPinHandle, Board_LED1, !PIN_getOutputValue(Board_LED1));
	UART_read(uart, &rxMsg, MEASURMENT_LEN_BYTES);
}

  • Hi Mega,

    Can you provide how exactly you added the task in?
    + any other modifications you made to simple_peripheral?

    This is so we can attempt to reproduce it on our side

    There's many points of possible failure here. I understand they work fine separately, when combined only BLE works - signals to me that they weren't combined correctly. My best guess is that you're running out of TI RTOS Heap, or Cstack heap.

    software-dl.ti.com/.../platform.html

    If you want to read up on these.

    Regards,
    Rebel
  • Hi Rebel,

    Many thanks for the quick reply.

    I managed to find the problem - the UART task was "starving" and didn't get CPU time.
    The two tasks had the same priority of 1.
    Once the UART task pend on the semaphore, the BLE task starts running. Although the semaphore is posted from the callback, the program doesn't go back to the UART task to perform the reading.

    By setting the UART task priority to 2, the problem was solved.

    Mor