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.

FreeRtos Generate Run Time Statistics

Other Parts Discussed in Thread: TMS570LS3137, HALCOGEN

Hi,

I use Tms570ls3137 and work on FreeRtos.I want to use vTaskGetRunTimeStats() API function. First of all

1."Collection of run time statistics is enabled by #defining configGENERATE_RUN_TIME_STATS as 1." , I did it,

2.portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()  I must configure it, But ı do not understand that  how can i use it.

Can i find a sample code for this  in Tms570ls3137 ? 

  • Hans,

    I can quickly check with our Halcogen team to see if we have an example.

    But, what I would recommend is to use PMU(performance monitoring unit) and implement these functions, as that would give you a granular count, but make sure your task doesn't take longer to expire the counters.

    portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()

    {   

    //Set-up PMU and enable the cycle counter   

    }

    portGET_RUN_TIME_COUNTER_VALUE()

    {

    //Return the cycle counter value when this function is called up on

    }

    To our understanding the first function(portCONFIGURE_TIMER_FOR_RUN_TIME_STATS) will be just called once to setup and start the counter, and the next function(portGET_RUN_TIME_COUNTER_VALUE) will be called at different instances to calculate the difference for computing the time spent between different events.

    Above are our understanding, so please refer to freeRTOS manuals to get more information on this port. Thanks.

  • I just tried this out, I think its worth noting, after I started the scheduler (using vTaskStartScheduler), i needed to raise the privilege level otherwise i would get an undefEntry error.

    #include "TI_RM57Lx_profiler.h"
    #ifndef USE_FREERTOS
    #define RAISE_PRIVILEGE
    #define RESET_PRIVILEGE
    #else
    #pragma SWI_ALIAS(prvRaisePrivilege, 1);
    extern BaseType_t prvRaisePrivilege( void );
    #define RAISE_PRIVILEGE BaseType_t xRunningPrivileged = prvRaisePrivilege ()
    #define RESET_PRIVILEGE if( xRunningPrivileged == 0 ) portSWITCH_TO_USER_MODE()
    #endif

    void initializeProfiler()
    {
    /* Enable PMU Cycle Counter for Profiling */
    RAISE_PRIVILEGE;
    _pmuInit_();
    _pmuEnableCountersGlobal_();
    _pmuResetCycleCounter_();
    _pmuStartCounters_(pmuCYCLE_COUNTER);
    RESET_PRIVILEGE;
    }

    uint32 getProfilerTimerCount()
    {
    RAISE_PRIVILEGE;
    return _pmuGetCycleCount_();
    portRESET_PRIVILEGE( xRunningPrivileged );
    RESET_PRIVILEGE
    }
  • Thanks Siddharth,

    FreeRTOS will create tasks that run in user mode by default, so you would need to elevate your privilege level to access the coprocessor 15.
    Makes sense.

    HalCoGen bare-metal normally leaves you in SYSTEM mode which has privilege.

    If you want to avoid the RAISE_PRIVILEGE and RESET_PRIVILEGE calls you can use the FreeRTOS API that creates a task *with privilege* then that particular task will be run in System mode. It's a differnet API to call when you create the task - see www.freertos.org/xTaskCreateRestricted.html