简体   繁体   English

C 中 MSP430FR6989 的时序功能

[英]Timing functions on the MSP430FR6989 in C

For a project I want to time how long a function takes.对于一个项目,我想计算 function 需要多长时间。 For this, I was thinking of using TimerA TA0 and a capture.为此,我正在考虑使用 TimerA TA0 和捕获。 However, after looking through the documentation, I was wondering if it is possible to capture the timer using an internal "message".但是,在查看文档后,我想知道是否可以使用内部“消息”来捕获计时器。 In the datasheet ( http://www.ti.com/lit/ds/symlink/msp430fr6989.pdf page 87, table at the bottom of the page) it is not really clear to me how to do this.在数据表( http://www.ti.com/lit/ds/symlink/msp430fr6989.pdf第 87 页,页面底部的表格)中,我不太清楚如何执行此操作。 It states the Port pins which can be used, but I am (obviously) not interested in that.它说明了可以使用的端口引脚,但我(显然)对此不感兴趣。 I was thus thinking if I was able to write to the TAxIV regitser, to just set the interrupt flag myself, but I'm absolutely not sure if it would work (I don't really think so, but I don't know why), I could use that to capture the timer.因此,我在考虑是否能够写入 TAxIV 注册器,自己设置中断标志,但我绝对不确定它是否会起作用(我真的不这么认为,但我不知道为什么),我可以用它来捕获计时器。

I also already looked at the example code, but there they use ACLK to as an input signal.我也已经看过示例代码,但他们使用 ACLK 作为输入信号。 So that is not of much use either.所以这也没有多大用处。

With kind regards and thanks in advance提前致以诚挚的问候和感谢

As shown in the Timer_A block diagram (figure 25-1) in the User's Guide, the capture signal must come from one of the four capture inputs.如用户指南中的 Timer_A 框图(图 25-1)所示,捕捉信号必须来自四个捕捉输入之一。

The last two inputs are always connected to GND and V CC , so you can trigger the capture manually by switching between these two inputs (see section 25.2.4.1.1).最后两个输入始终连接到 GND 和 V CC ,因此您可以通过在这两个输入之间切换来手动触发捕获(参见第 25.2.4.1.1 节)。

The answer is (all thanks go to CL. ,see above, who gave the answer):答案是(感谢 go 到 CL。,见上文,谁给出了答案):

for initialisations:初始化:

TA0CCTL1 = CM_3 | CCIS_1 | SCS | CAP; // could put in interrupt here
TA0CTL = TASSEL__SMCLK | MC__CONTINUOUS; // setting the timer up with the SMCLK

and for usage, meaning capturing the timer:并且对于使用,意味着捕获计时器:

TA0CCTL1 ^= CCIS0 // TA0CCR1 = TA0R, toggling the CCIS0 bit to switch between Vcc and GND

and then just reading the capture register out.然后只是读取捕获寄存器。

This answer is here to make it easier to read, for the full answer see my conversation with CL.这个答案是为了更容易阅读,完整的答案请参见我与 CL 的对话。 above, whom gave me the answer.上面,谁给了我答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM