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.
你(们)好。
我尝试通过在项目中包含 HalCoGen 04.06.00生成的 sys_PMU.asm 和 sys_pmu.h 来使用 PMU。 我的代码结构的形式为:
_pmuInit_(); _pmuEnableCountersGlob_(); _pmuSetCountEvent_(0、0); while (真) //嵌入式软件:无限循环 { _pmuResetCyclCounter_(); _pmuStartCounter_(0x1); [此处提供一些代码...] _pmuStopCounter_(0x1); int count=_pmuGetCycleCount_(); [此处提供更多代码...] } }
但是、PMCNTENSET.C 位(周期计数使能)始终保持禁用状态、因此计数器不会计数。 如果我使用调试器启用该位、一切看起来都很好。
我是否忘记调用另一个函数来启用该位、或者我对被调用函数的参数是否错误?
谢谢!
你好、Chuck、
PMU 包含3个事件计数器和1个周期计数器。 它们是不同的计数器。 您的代码不启用周期计数器、但您从周期计数器读取该值。 您为事件#0定义事件计数器0、但启动和停止事件计数器1、 然后读取周期计数器。
如果 您使用 PMU 对周期进行计数、请使用 以下修改后的代码:
_pmuInit_();
_pmuEnableCountersGlobal_();
while
(TRUE)
// embedded software: endless loop
{
_pmuResetCycleCounter_();
_pmuStartCounters_(0x1);
_pmuStartCounters_(pmuCYCLE_COUNTER);
[Some code here ...]
_pmuStopCounters_(0x1);
_pmuStopCounters_(pmuCYCLE_COUNTER);
int
count=_pmuGetCycleCount_();
[More code here ...]
}
}
您好 QJ、
感谢您的深入了解。
此致。