ARM Cortex M4(或M3)上的循环计数器? [英] Cycle counter on ARM Cortex M4 (or M3)?
问题描述
我正在尝试在 Cortex M4 上分析 C 函数(从中断调用,但我可以提取它并在其他地方分析它).
I'm trying to profile a C function (which is called from an interrupt, but I can extract it and profile it elsewhere) on a Cortex M4.
计算此函数中通常使用的周期数的可能性有哪些?函数应该在大约 4000 个周期内运行,所以我猜 RTC 不是一个选项,并且从反汇编中手动计算周期可能很痛苦 - 并且只有在平均时才有用,因为我想用典型的闪存/内存对典型的流进行分析使用模式.
What are the possibilities to count the number of cycles typically used in this function ? Function shall run in ~4000 cycles top, so RTC isn't an option I guess, and manually counting cycles from disassembly can be painful - and only useful if averaged because I'd like to profile on a typical stream with typical flash / memory usage pattern.
我听说过循环计数器寄存器和 MRC 指令,但它们似乎可用于 A8/11.我在 cortex-Mx micros 中没有看到过这样的指令.
I have heard about cycle counter registers and MRC instructions, but they seem to be available for A8/11. I haven't seen such instructions in cortex-Mx micros.
推荐答案
查看定义的 DWT_CYCCNT 寄存器 此处.请注意,该寄存器与实现相关.谁是芯片供应商?我知道 STM32 实现提供了这组寄存器.
Take a look at the DWT_CYCCNT register defined here. Note that this register is implementation-dependent. Who is the chip vendor? I know the STM32 implementation offers this set of registers.
这篇文章提供了使用 DWT 周期计数器寄存器进行计时的说明.(请参阅 2009 年 12 月 11 日 - 下午 06:29)
This post provides instructions for using the DWT Cycle Counter Register for timing. (See the post form 11 December 2009 - 06:29 PM)
这篇堆栈溢出帖子也是关于如何使用 DWT_CYCCNT 的示例.
This Stack overflow post is an example on how to DWT_CYCCNT as well.
这篇关于ARM Cortex M4(或M3)上的循环计数器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!