This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Gettickcount or its equivalent in msp430?

Hi i would like to test the throughput of the msp430 device .for which i like to get the time stamp in different places in the firmware to calculate the time delay in different interefaces.

will it be possible to get the time stamp or time elapsed value by using gettickcount kind of routines ?

 

Please advice me your opinions.

 

Thanks and Regards

LK

  • It's possbile, but not as easy as on the PC where the Pentium processor has an internal tick counter.

    You'll need to set SMCLK or ACLK to the same clock frequency as MCLK (for ACLK it is only possible on newer devices), then set up a timer to be clocked by SMCLK or ACLK, enable overflow interrupt and write an ISR which counts the overflows. If you never disable interrupts for longer than ~65500 clock cycles, the overflow counter will hold the upper 16 bit (or 32 bits if you use a long int) and the timer counter register the lower 16 bits of the passed cpu ticks since starting the timer. It is a bit difficult, however, to retrieve the current value, as it is possible that an overflow occurs between collecting the two 16bit values (orbetween reading the upper and lower 16 bit of the long counter, if used).

    Also, this approach  consumes some processor time too, as every 65536 cpu cycles the ISR is entered and consumes 20-30 cycles for updating the overflow counter.

    You can, however, use the dividers for SM/ACLK and/or timer to break down the count frequency by a factor of up to 64. This reduces the resolution of the tick counter by 64, but also reduces the cpu usage by the same factor. And maybe eliminates the need of using a long value for the overflow counter.

**Attention** This is a public forum