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.

TMS570 PMU Counters Not Starting

Other Parts Discussed in Thread: TMS570LS1227, HALCOGEN

Hi

I'm looking for some assistance with regards to the operation of the PMU on my TMS570LS1227.

I'm using the PMU Code generated by Halcogen version 4.05.01, I have no MPU regions enabled and all my code is running in privileged mode (I haven't set user mode at all after the Halcogen generated startup routine).


I'm doing the following in the HW Initialisation Routine:

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

Then around code that I wish to profile I'm using the following macros:

#define START_PMU_COUNTER(var_prefix) \
{\
    _pmuResetCounters_();\
    _pmuStartCounters_(pmuCOUNTER0);\
    var_prefix##_cycles_start = _pmuGetEventCount_(pmuCOUNTER0);\
}\

#define END_PMU_COUNTER(var_prefix) \
{\
    uint32 temp;\
    _pmuStopCounters_(pmuCOUNTER0);\
    var_prefix##_cycles_end = _pmuGetEventCount_(pmuCOUNTER0);\
    temp = var_prefix##_cycles_end - var_prefix##_cycles_start;\
    if(var_prefix##_total_cycles < temp)\
    var_prefix##_total_cycles = temp;\
}\


The variables that come out of this are always zero.  Further I have attempted to use the _pmuGetCycleCount_() routine but this also always returns zero.


I should mentioned that I have based all of this off the application note for Hercules uCs found on the tms570ls1227 page.


Any assistance would be greatly appreciated.

  • David,

    Before I dig on to your code, if you are interested in the cycle count, you can just use the cycle counter directly as shown below.

    _pmuInit_();

    _pmuResetCounters_();

    _pmuStartCounters_(pmuCYCLE_COUNTER);

    //CODE TO BE BENCHMARKED
    ...
    ...
    ...

    _pmuStopCounters_(pmuCYCLE_COUNTER);

    varTotalCycleCount = _pmuGetCycleCount_();

    Pls let me know if this works.
  • Hi Karthik

    Thanks for your response.

    I can confirm that the cycle counter now works with the addition of _pmuStartCounters_(pmuCYCLE_COUNTER) I had assumed it was started by default when enabled. Thank you.

    With regards to the events not counting, I have just read the following excerpt on the arm:

    "The PMU only counts events when non-invasive debug is enabled, that is, when either DBGEN or NIDEN inputs are asserted."

    Is there a DBGEN bit in the CP15 registers that must be asserted when debugging via JTAG for the PMU to count events?

    Best Regards

    Dave Wright