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.

Task construct failer UART cc2650

Hello, sry for my bad eng

i have a problem w Uart when used a few tasks

Task_Struct task0Struct, task1Struct;
Char task0Stack[TASKSTACKSIZE], task1Stack[TASKSTACKSIZE];
Task_Handle uartTask, vmTask;
Semaphore_Struct sem0Struct;
Semaphore_Handle vmSem;
UART_Handle hUART;
UART_Params params;


Void uartFxn(UArg a0, UArg a1){

        if(!hUART){
	    UART_Params_init(&params);
	    params.readMode     = UART_MODE_BLOCKING;
	    params.writeDataMode= UART_DATA_BINARY;
	    params.readTimeout  = 1000;
	    params.readCallback = NULL;
	    params.readEcho     = UART_ECHO_OFF; //Not needed on CC26XX implementation as not implemented
	    params.baudRate     = 9600;
	    hUART = UART_open(Board_UART0, &params);
	}
	if (!hUART) {
	            System_abort("Error initializing UART\n");
	}
	uint32_t i = 0;
	    while(1){

	    	System_flush();
	    	System_printf(" %d", i);
	    	i++;
	    	if(i==5){
	    		Semaphore_post(vmSem);
	    	}

			Task_sleep(1000000 / Clock_tickPeriod);

	    }
}

void vmFxn(void){

	while(1){
		Semaphore_pend(vmSem, BIOS_WAIT_FOREVER);
		System_flush();
		System_printf("asdasdasdasd");
		System_flush();
				System_printf("asdasdasdasd");
				break;
	}

}

/*
 *  ======== main ========
 */
int main(void)
{
    Task_Params taskParams;
    Semaphore_Params semParams;

    /* Call board init functions */
    Board_initGeneral();

    /* Construct BIOS objects */
    Task_Params_init(&taskParams);
        taskParams.stackSize = TASKSTACKSIZE;
        taskParams.stack = &task0Stack;
        taskParams.priority = 2;
        taskParams.instance->name = "vmFxn";
        Task_construct(&task0Struct, (Task_FuncPtr)vmFxn, &taskParams, NULL);
        vmTask = Task_handle(&task0Struct);

        taskParams.stack = &task1Stack;
        taskParams.priority = 1;
        taskParams.instance->name = "uartFxn";
        Task_construct(&task1Struct, (Task_FuncPtr)uartFxn, &taskParams, NULL);
        uartTask = Task_handle(&task1Struct);

        Semaphore_Params_init(&semParams);
        semParams.mode = Semaphore_Mode_BINARY;
        Semaphore_construct(&sem0Struct, 0, &semParams);
        vmSem = Semaphore_handle(&sem0Struct);


    /* Start BIOS */
    BIOS_start();

    return (0);
}

when the project starts, UART activates successfully

but when i change the task, UART crashes and doesnt work till the programm is finished

  • What version of TI-RTOS are you using? Do you have the System_printf output going to the UART? Can you look in RTOS Object Viewer (ROV) to see the peaks for the System Stack (Hwi->module) and the Tasks (Tasks->Detailed). You can do a BIOS->Scan for Errors also. Can you be more specific about what "UART crashes" means? Does the application crash or does the UART not work?

    Todd
  • i use to-rtos for cc26XX

    I changed the project for test
    should write 1 2 3 4 access 5 6 7 8 ...
    but i get 1 2 3 4 access 5 (empty) (empty) (empty) (empty)...

    Task_Handle uartTask, vmTask;
    Semaphore_Struct sem0Struct;
    Semaphore_Handle vmSem;
    UART_Handle hUART;
    UART_Params params;
    char rx_accept[] = "Access";

    void vmFxn(void){

    while(1){
    Semaphore_pend(vmSem, BIOS_WAIT_FOREVER);
    UART_write(hUART, rx_accept, strlen(rx_accept));
    break;
    }
    }

    void uartFxn(UArg a0, UArg a1) {
    uint32_t i = 0;
    while(1){
    sprintf(rxBuf1, " %d", i);
    UART_write(hUART, rxBuf1, strlen(rxBuf1));
    i++;
    Task_sleep(1000000 / Clock_tickPeriod);
    if(i==5){
    Semaphore_post(vmSem);
    }
    }
    }

    int main(void){

    PIN_Handle ledPinHandle;
    Task_Params taskParams;
    Semaphore_Params semParams;

    Board_initGeneral();
    Board_initUART();

    if(!hUART){
    UART_Params_init(&params);
    params.readMode = UART_MODE_BLOCKING;
    params.writeDataMode= UART_DATA_BINARY;
    params.readTimeout = 1000;
    params.readCallback = NULL;
    params.readEcho = UART_ECHO_OFF; //Not needed on CC26XX implementation as not implemented
    params.baudRate = 9600;
    hUART = UART_open(Board_UART0, &params);
    }
    if (!hUART) {
    System_abort("Error initializing UART\n");
    }

    Task_Params_init(&taskParams);
    taskParams.stackSize = TASKSTACKSIZE;
    taskParams.stack = &task0Stack;
    taskParams.priority = 2;
    taskParams.instance->name = "vmFxn";
    Task_construct(&task0Struct, (Task_FuncPtr)vmFxn, &taskParams, NULL);
    vmTask = Task_handle(&task0Struct);

    taskParams.stack = &task1Stack;
    taskParams.priority = 1;
    taskParams.instance->name = "uartFxn";
    Task_construct(&task1Struct, (Task_FuncPtr)uartFxn, &taskParams, NULL);
    uartTask = Task_handle(&task1Struct);


    Semaphore_Params_init(&semParams);
    semParams.mode = Semaphore_Mode_BINARY;
    Semaphore_construct(&sem0Struct, 0, &semParams);
    vmSem = Semaphore_handle(&sem0Struct);
    BIOS_start();
    return (0);
    }


    I checked the ROV, and everything is in order
  • the problem is solved
    BUT
    in first time task is performed
    but if i want use "Semaphore_post(vmSem);" again, its does not work

  • the problem is solved
    BUT
    in first time task is performed
    but if i want use "Semaphore_post(vmSem);" again, its does not work
  • I'm marking this thread as answered. If you want to continue to debug what was the problem, please feel free to add a response.

    Todd