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.

Cycle count is always zero when Performance Measurement Unit (PMU) is used in TI Hercules TMS570L

Other Parts Discussed in Thread: HALCOGEN

I am referring the data sheet spna138a as a reference to measure the time taken for execution of my part of code.

I used the same example given in the data sheet to measure the time. However ,the cycle count is always zero ie there is no update of any variable

Do I need to configure anything in Halcogen to enable PMU? I just included the sys_pmu.h and used the following API

The API should invoke the  assembly code right ? But I cannot see it when I debug??

Code is added for reference 

	_pmuInit_();
	_pmuEnableCountersGlobal_();
	_pmuSetCountEvent_(pmuCOUNTER0, PMU_CYCLE_COUNT); // PMU_INST_ARCH_EXECUTED

	_pmuResetCounters_();
	_pmuStartCounters_(pmuCOUNTER0);
	cycles_PMU_start = _pmuGetEventCount_(pmuCOUNTER0);

	/* Place the task here to measure the time */

	//for(i = 0 ; i < 100000; i++);
	for(i = 0 ; i < 10000; i++)
	{
		for(j = 0 ; j < 10000; j++);
	}
/*
	for(i = 0 ; i < 10000; i++)
	{
		for(j = 0 ; j < 10000; i++);
	}
*/
	_pmuStopCounters_(pmuCOUNTER0);
	cycles_PMU_end = _pmuGetEventCount_(pmuCOUNTER0);
	cycles_PMU_measure = cycles_PMU_end - cycles_PMU_start;

	/* Measure the time compensation */
	_pmuResetCounters_();
	_pmuStartCounters_(pmuCOUNTER0);
	cycles_PMU_start = _pmuGetEventCount_(pmuCOUNTER0);

	_pmuStopCounters_(pmuCOUNTER0);
	cycles_PMU_end = _pmuGetEventCount_(pmuCOUNTER0);
	cycles_PMU_comp = cycles_PMU_end - cycles_PMU_start;

	/* Calculate Time */
	cycles_PMU_code = cycles_PMU_measure - cycles_PMU_comp;
	time_PMU_code = cycles_PMU_code / (f_HCLK); // time_code [us], f_HCLK [MHz]

  •  The PMU settings are set by default in HALCoGen like this.

  • Dino,

         SPNA138a was published in 2011 with an older version of HALCoGen and needs to be updated.

         Below is the flow I'm using with the latest version of HALCoGen 04.05.02 and it work well for me.

         /* Include Files */
    #include "HL_sys_pmu.h"    // for execution time (debug)
     
         /* Globals */
    const char Version[]      = "00.00.01.08";
    const char Compile_Date[] = __DATE__;
    const char Compile_Time[] = __TIME__;
    float System_Clock  = GCLK_FREQ*1000000; // GCLK_FREQ defined by HALCoGen as 160,000,000Hz
         uint32 pmuCalibration;
     
         main () {
               int pmuCount, Exec_Time;
     
     
               /* PMU initialization */
               _pmuInit_();
     
               /* PMU calibration */
               _pmuEnableCountersGlobal_();
               _pmuResetCounters_();
               _pmuStartCounters_(pmuCYCLE_COUNTER);
               _pmuStopCounters_(pmuCYCLE_COUNTER);
               pmuCalibration=_pmuGetCycleCount_()
     
     
               /* Start PMU counter */
               _pmuResetCounters_();
               _pmuStartCounters_(pmuCYCLE_COUNTER)
     
               /* Code to be measured */
               Printf(“Hello World!/n”) // Note that printf uses CIO|JTAG and halts the processor
     
               /* Stop PMU counter */
               _pmuStopCounters_(pmuCYCLE_COUNTER);
     
               /* Get CPU cycle count */
               pmuCount =_pmuGetCycleCount_();
               Exec_Time = pmuCount - pmuCalibration; // subtract for the start and stop delay
     
               printf("Execution Time: %1.3f uS\n",(float)Exec_Time/System_Clock);
     }

    Regards,

    Forum Support