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.

Measuring interrupt blocking times

Other Parts Discussed in Thread: SYSBIOS

Hello,

I want to analyze interrupt blocking times in the kernel during application run-time. Let it be either due to task switches or other kernel functions with critical sections. I guess that we cannot do a formal analysis in TI-RTOS, so my idea is, to watch an application for a certain amount of time and monitor the execution time spent between Hwi_disable() and Hwi_restore().

Is that possible with on-board tools in TI-RTOS/CCS and without hacking the Hwi module? I've tried the system analyzer, but I could not find this particular information. I'm using CC13xx/CC26xx.

  • Hi Richard,

    Have you looked the benchmarks in the SYS/BIOS release notes? You can add Hwi hook functions also and put in whatever you want.

    Regarding System Analyzer, it's not clear what exactly you are trying to measure. Did you enable Hwi, Swi and Task logging?

    Todd
  • Hi Richard --


    We don't have what you're looking for "built-in" unfortunately.  A technique we've used around here when debugging possible latency problems is to program a timer for periodic interrupt.  And the write a timer ISR and have the ISR keep track and store the max timer "count" register that it sees.  The specifics of the timers vary, but many of them generate an interrupt when they reach a programmed threshold and then reset back to 0 and start counting again. If you read that counter register in your timer ISR, you get a pretty good idea of the worst case interrupt latency since the counter will be counting until you finally take the ISR and read it. You want to program the timer for some odd frequency so that it "sweeps" through your application and doesn't end up in some beat frequency relative to other timing in your app.

    An engineer here did this just recently for an MSP432 debug session. I'll see if she can send her test code across. The same logic should apply for the CC13xx/26xx although the timer details might differ.  Some count up and reset to 0 when they reach threshold. Some count down to 0 and and reset to the threshold. Some have a compare register that gets updated and keep on counting.

    -Karl-

  • Hi Richard,

    Here is the code for my simple test for measuring latency using a timer.  This was built for MSP432, so you will need to change the Timer.h include path accordingly.

    First include the Timer.h header file and define the period of the timer you will create to have p period of some prime number (this prevents the timer ISR from coinciding too frequently with other periodic ISRs in the system).  The variable, maxTimerCount, will hold the maximum latency for the timer ISR.

    #include <ti/sysbios/family/arm/msp432/Timer.h>

    /* Timer for testing interrupt latency */
    #define TIMER_PERIOD 307

    static Timer_Handle timer;
    uint32_t maxTimerCount = 0;
    uint32_t timerFuncCount = 0;

    The timer ISR gets the current timer count and subtracts the timer period.  That's the number of counts that it took from the time the timer period elapsed until the ISR was run.  Then restart the timer.


    /*
     *  ======== timerFunc ========
     */
    void timerFunc(UArg arg)
    {
        uint32_t count;

        timerFuncCount++;

        count = Timer_getCount(timer);
        count -= TIMER_PERIOD;

        if (count > maxTimerCount) {
            maxTimerCount = count;
        }

        Timer_start(timer);
    }

    Here is the code for creating the timer.  We make the timer one-shot and restart it in the ISR.  This simplifies the math for calculating the latency.  I also added code to print out the timer frequency, which you can use to convert latency from timer ticks to microseconds.

        Timer_Params timerParams;

        /* Create timer to check interrupt latency */
        Timer_Params_init(&timerParams);

        timerParams.period = TIMER_PERIOD;
        timerParams.periodType = Timer_PeriodType_COUNTS;
        timerParams.runMode = Timer_RunMode_ONESHOT;
        timerParams.startMode = Timer_StartMode_USER;

        Error_init(&eb);
        timer = Timer_create(Timer_ANY, timerFunc, &timerParams, &eb);
        Timer_getFreq(timer, &freqHz);
        System_printf("Timer frequency: %d\n", freqHz.lo);

    I hope this helps.

    Best regards,

    Janet