Hello,
I am trying to measure execution time using the PMU on the LAUNCHXL2-TMS57012. I have read the TI guide on the subject (SPNA138A). However, I am having some issues with the PMU. I am initializing the PMU as described in the guide, but every call to "_pmuGetEventCount_" returns 0 -- I assume this is because I have failed to properly set up the PMU, but I'm not sure what I have done wrong or left out. I have included an excerpt of my sys_main.c:
void main(void) { // measurement init _pmuInit_(); _pmuEnableCountersGlobal_(); _pmuSetCountEvent_(pmuCOUNTER0, PMU_CYCLE_COUNT); // run the code to get everything prepped for (loop_count_prep=0;loop_count_prep<loop_count_prep_max;++loop_count_prep) { // user code } _pmuResetCounters_(); _pmuStartCounters_(pmuCOUNTER0); cycles_PMU_start = _pmuGetEventCount_(pmuCOUNTER0); float cycles_test = _pmuGetCycleCount_(); // run the actual code // take measurements _pmuStopCounters_(pmuCOUNTER0); cycles_PMU_end = _pmuGetEventCount_(pmuCOUNTER0); cycles_PMU_measure = cycles_PMU_end - cycles_PMU_start; _pmuResetCounters_(); // take another instant measurement for compensation _pmuStartCounters_(pmuCOUNTER0); cycles_PMU_start = _pmuGetEventCount_(pmuCOUNTER0); _pmuStopCounters_(pmuCOUNTER0); cycles_PMU_end = _pmuGetEventCount_(pmuCOUNTER0); // compensate cycles_PMU_comp = cycles_PMU_end - cycles_PMU_start; // get the execution time cycles_PMU_code = cycles_PMU_measure - cycles_PMU_comp; time_PMU_code = cycles_PMU_code / (f_HCLK); // time_code [us], f_HCLK [MHz] }
I have not modified sys_pmu.h or sys_pmu.asm from the output of HALcogen, which I am using to configure the device. As the PMU is (should be) configured to count CPU clock cycles and should be enabled, I'm not sure what the issue is. If anyone has any suggestions or common fixes I would greatly appreciate it.