简体   繁体   中英

Timing functions on the MSP430FR6989 in C

For a project I want to time how long a function takes. For this, I was thinking of using TimerA TA0 and a capture. 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. 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.

I also already looked at the example code, but there they use ACLK to as an input signal. 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.

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).

The answer is (all thanks go to CL. ,see above, who gave the answer):

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. above, whom gave me the answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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