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-CC1310: UART_write() is blocking the ideal task

Part Number: LAUNCHXL-CC1310

Tool/software: TI-RTOS

Hello, everyone.

I am having a program in which I am using UART task and gpio interrupt as follows.

void buttonCallbackFxn(PIN_Handle handle, PIN_Id pinId) {
    SetPinOutput();
    PIN_setOutputValue(ledPinHandle, Board_LED0, 1);
    CPUdelay(80000*100);
    PIN_close(ledPinHandle);
    if(init==false)
    {
        GetFlags();
    }
    SetPinInput();
}

bool GetFlags()
{
    ui8Count=4;
    buffer[0]=SYNC;
    buffer[2]= GET_FLAGS;
    buffer[1]=ui8Count;
    buffer[3]=ui8GenerateCheckSum(buffer, ui8Count);
    WaitForACK=true;

    UART_write(uart,buffer, ui8Count);
    Clock_start(clkHandle);
    return(true);
};

Void UartTaskFxn(UArg arg0, UArg arg1)
{
    UART_Params_init(&uartParams);
    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readDataMode = UART_DATA_BINARY;
    uartParams.readTimeout = 100000;
    uartParams.readReturnMode = UART_RETURN_FULL;
    uartParams.readEcho = UART_ECHO_OFF;

    uartParams.baudRate = 9600;
    uart = UART_open(Board_UART0, &uartParams);

    if (uart == NULL) {
        System_abort("Error opening the UART");
    }

    while (1)
    {
        if(init==true)
        {
            UART_write(uart,buffer, 4);
            init=false;
            Clock_start(clkHandle);

        }
        if((WaitForResponse==true) || (WaitForGetResponse==true))
        {
            if(PktState==PKT_DATA)
            {
                //                for(i=i;i<datalength;i++)
                //                {
                UART_read(uart, buff,1);
                buffer[i]=buff[0];
                //                }
                //                i=i+datalength;
                i++;
                //               Semaphore_post(txSemaphoreHandle);

            }
}
}
}

When GPIO interrupt occurs then GetFlags() function is called and when it executes the  UART_write(uart,buffer, ui8Count); Then in the ROV ideal task shown to be blocked because of internal error and the whole program stops functioning. Please help me to solve the issue.

  • Hello Priti,
    What is the state of the WaitForResponse, WaitForGetResponse and PktState? Is there something to block the while(1) loop in the UartTaskFxn? It will be good to make sure that this while(1) loop gets blocked and does not always loop forever.
    Regards,
    Prashanth
  • In above code there is nothing which blocks while(1) loop in UART function WaitForResponse, WaitForGetResponse and PktState are just flags to indicate which condition is there and what data is expected from UART. But as you suggested I also used semaphore in while(1) loop to block it. But I am getting the same result as that of the previous results only one differnce UARTTask is also blocked because of semaphore. Here is the screen shot.

  • Hello ,I met this problem too, Is your problem solved?

  • Hello Tom,

    I have solved this problem few days back. Let me tell you where is the problem.

    In TI-RTOS each and every task is having one while(1) loop. My program also had tasks like RF TX, RF Rx and UART RX TX. Out of these task RF Tx and RF Rx task were running only when they were meeting certain condition required by my application. But there was no such condition for UART task. So Uart task were running continuously. Though TI-RTOS supports multitasking, there should not be a task which is running continuously and it is non-blocking. This was the problem which was stopping the ideal task and whole program execution.

    To make UART task blocking I added one condition immediately after entering while(1) loop, here is the example. You can write your own condition as per the application requirement.

    UART_Params_init(&uartParams);
        uartParams.writeDataMode = UART_DATA_BINARY;
        uartParams.readDataMode = UART_DATA_BINARY;
        uartParams.readReturnMode = UART_RETURN_FULL;
        uartParams.readEcho = UART_ECHO_OFF;
        uartParams.baudRate = 9600;
        uart = UART_open(Board_UART0, &uartParams);
    
        if (uart == NULL) {
            System_abort("Error opening the UART");
        }
    
        while (1)
        {
            if(boolReady)
            {
                if(boolInit) // If the device is Reseted and Get Bootloader command is to be sent
                {

    Now the program is running smoothly.

     

  • Thanks Very much!