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 |