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.

TMS570LC4357: PMU counter seems to be wrong

Part Number: TMS570LC4357

Hello,

We are using a TMS570LC4357ZWT (launchpad) and we want to monitor our time cycle.

For that we use the PMU configured with HCG :

- PMU Counters enable

- Event Export enable

- Counter Event 0/1/2 set to 0x11 (PMU_CYCLE_COUNT)

In HCG HCLK is set to 100 MHz.

Our code based on example spna138a : 

Initialization :

#define f_HCLK (float) 100.0

volatile unsigned long cycles_PMU_start, cycles_PMU_end, cycles_PMU_measure, cycles_PMU_comp,cycles_PMU_code,cycles_PMU_prev,cycles_PMU;
volatile float time_PMU_code;

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

cycles_PMU_prev = 0;

while(1){

_pmuResetCounters_();
_pmuResetEventCounters_();
_pmuStartCounters_(0x80000007U);
cycles_PMU_prev = _pmuGetEventCount_(pmuCOUNTER0);

/* Code to be measured */

_pmuStopCounters_(pmuCOUNTER0);

cycles_PMU = _pmuGetEventCount_(pmuCOUNTER0);

cycles_PMU_measure = cycles_PMU_prev - cycles_PMU;
time_PMU_code = cycles_PMU_measure / (f_HCLK); // time_code [us], f_HCLK [MHz]

}

So first of all, we have seen that we must star all counters (_pmuStartCounters_(0x80000007U);) instead of one if we want to have data in cycles_PMU. Is it normal?

2nd : With our code we retrieve always the same value in time_PMU_code (42889676.0) independent of the code to be measured, the code duration as been estimated with scope and GPIO.

We think we have an issue in our code...

If somebody have an idea to help us...

Thanks in advance,

Kind regards,

Alain.