Other Parts Discussed in Thread: MSP430F2013
Hello All,
I am implementing a simple code to generate a 1 sec delay in MSP430F2013. I am using the VLOCLK with a frequency of 12KHz.
There are two ways I am doing this
1. The first code uses timer A and it's ISR and toggles on LED every 1 sec. I have used VLOCLK and Timer A CLK = VLOCLK. Since I need a 1 sec delay, I have used the 16 bit timer values as 12000.
This method is giving me a correct 1 sec delay.
2. The second way I have implemented this is by setting MCLK = VLOCLK. I have then written a for loop with loop count =12000. I am doing just one NOP inside the for loop.
while(1){
for(i=0;i<12000;i++){
__no_operation();
}
P1OUT ^= P1OUT; //Toggle LED
}
Technically both the methods should give me a 1 sec delay. However only Timer A seems to give me an accurate 1 sec delay.
In the seond method the LED seems to flash faster than the first one.
Can anyone tell me what is the differece between the two methods ?
Regards,
Sharwari