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.

MSP430F1611: Calculating execution time

Part Number: MSP430F1611

Hi all:

This is for a school project. 

I measured clock speed of the mcu at 3V - it turned out to be 4.31MHz. Using an oscilloscope, I found out my code takes 0.176ms to execute. However, when I calculate the time using the clock cycles of the code(which I counted manually), with a clock speed of 4.31MHz, the value was 0.237ms. Even if I use the clock speed of 4MHz, as given in the datasheet, the time taken is 0.255ms, which is still way off than what I get using the oscilloscope. The following table shows the assembly generated and the corresponding clock cycles as taken from the datasheet. If I assume that add #1, -4(r4) takes 4 clock cycles rather than 5, my values have very little difference. I am not sure what the reason is for this. Can anyone suggest?

Assembly generated Clock cycles
push r4 3
mov r1, r4 1
add #2, r4 2
sub #2, r1 2
mov #0, -4(r4) 5
add #1, -4(r4) 5 x200
add #2, r1 2
pop r4 2
ret 3
Total 1020
  • Have there been any optimizations on the hardware that is causing the instruction to be completed in fewer clock cycles?
  • #0, #1, and #2 come from the constant generator, so you have to treat them as if they were register values.

    Table 3-16 of the User's Guide assumes that constants "#N" are unusual constants that must be read from the instruction stream. (The "#N" entry has exactly the same timings as the previous "@‍Rn+" entry because such constants are actually implemented by the assembler as "@‍PC+".) If the assembler can use the constant generator, you save one cycle and one word.

**Attention** This is a public forum