ARM Cortex M4(或M3)上的周期计数器? [英] Cycle counter on ARM Cortex M4 (or M3)?

查看:637
本文介绍了ARM Cortex M4(或M3)上的周期计数器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Cortex M4上调试一个C函数(这个函数是从一个中断调用的,但是我可以在Cortex M4中提取它,并在其他地方进行配置文件)。

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 PM的帖子)

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆