简体   繁体   中英

MSP430 TI while loop duration

I am programming a simple program on the TI MSP430.

I have a counter set up in C:

while (P1IN & BIT1)
{
counter++;
}

So when the pin is high, it counts up by one. I am wondering how long this takes?

I need to do some calculations with counter and need the duration of one while loop. In other words, say counter = 1234 in the end, how can I get a value of seconds?

How can I get this? Should I export the ASM code and see how long each instruction set takes? This seems tedious.

You can try: 1. Toggle any free port pin at the start and end of the loop and monitor the duration on CRO(If you have necessary equipment).

OR

2.Look into disassembly listing(ASM code),read instruction manual and based on CPU clock calculate the loop time.

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