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/CC2640R2F: Getting Task states

Part Number: CC2640R2F

Tool/software: TI-RTOS

I am working on CC2640R2F and I am having stability issues, such as the application deadlocks, stalls or hangs at a Hwi or somewhere else. Since I wish that my application to recover in those cases, I enabled watchdog and it is functioning. Furthermore, I enabled the UART prints so that I can log some information to debug the problem. Now I am having problem to print the currently running Tasks and their states. Furthermore, I would like to print their call stacks using UART if possible.

I tried using "Task_Object_count()" to get the total number of tasks but it returned only 1, instead there are 5. Moreover, I tried to get first task handle using "Task_Object_first()" and tried to reach other tasks using "Task_Object_next()", however I can only reach only 1 task again.

Is there an easy way to get the task handles (instead of getting the handles where they are created) at watchdog callback function? Is it possible to get their call stack at watchdog callback function?

  • Hi Kivanc,

    The reason why you're seeing only 1 handle and one handle from those API is because they only look at statically created objects.

    In other words, tasks generated at runtime aren't going to be looked at in these instances. However, this isn't the case for Task_Object_next() or first. Are you sure you're not getting more handles? Can you post the code you used?

    You can see documentation on this here: software-dl.ti.com/.../index.html

    Regards,
    Rebel
  • Hi Rebel,

    Thanks for your reply. You can find my watchdog callback function below. I get the output below the code after watchdog is triggered. I also debug the code and observed that the while loop is only having 1 cycle.

    void WatchdogResetTimer()
    {
        if (watchdogHandle)
        {
            Watchdog_clear(watchdogHandle);
        }
    }
    
    void WatchdogChangeTimer(uint32_t newTime)
    {
        if (watchdogHandle)
        {
            tickValue = Watchdog_convertMsToTicks(watchdogHandle, newTime);
            Watchdog_setReload(watchdogHandle, tickValue);
            WatchdogResetTimer();
        }
    }
    
    void watchdogCallback(UArg handle)
    {
        WatchdogChangeTimer(1000);
        printRemainingPrints();
        printf0("Watchdog is triggered!");
        printRemainingPrints();
        Task_Handle taskHandle = Task_Object_first();
    
        while(taskHandle != NULL){
            WatchdogResetTimer();
            printf1("Task Count: %d", Task_Object_count());
            printRemainingPrints();
            printf2("State:%d Pri:%d", Task_getMode(taskHandle), Task_getPri(taskHandle));
            printRemainingPrints();
            taskHandle = Task_Object_next(taskHandle);
        };
        printRemainingPrints();
    
        while(1){
        }
    }

    Watchdog is triggered!

    Task Count: 1

    State:2 Pri:5

    P.S. The printfX function is similar to Display_print function (prints outputs to UART). For controlling UART I created a task, and when printfX functions are called, the print strings are enqueued, and the when the task iterates, the UART prints them. Since Watchdog prevents the UART task to run, I wrote a similar function ( "printRemainingPrints()" ) for processing the queue at the watchdog function.