Hi all,
I'm having problem resetting the low power mode so that I can set it to different setting. I looked up some examples..here's my code.. I tried to use wait function between loop but it seems the problem with exiting the LPM0 and entering LPM0 again. Thanks in advance.
#include <msp430x20x3.h>
void wait(int ms);
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= 0x0C; // P1.2 and P1.3 output
P1SEL |= 0x0C; // P1.2 and P1.3 TA1/2 otions
for (int i=1; i<3001; i++) // Rotate 10 times
{ TACCTL0=CCIE;
CCR0 = 23260-1; // PWM Period/2
CCTL1 = OUTMOD_7; // CCR1 reset/set
if( i%200==0 )
{ __disable_interrupt();
CCR1=1582 ; //1582= 90 Degree UP
TACTL = TASSEL_2+ MC_1; // ACLK, up-down mode
_BIS_SR(LPM0_bits+GIE);__enable_interrupt();
// CCTL1=0;
}
else if( i%300==0 )
{ __disable_interrupt();
CCR1= 1977; // 1977=Fall Back
TACTL = TASSEL_2+ MC_1; // ACLK, up-down mode
_BIS_SR(LPM0_bits+GIE); __enable_interrupt();
}
else if(i%1==0)
{ __disable_interrupt();
CCR1=700; //700= 0 Degree
TACTL = TASSEL_2+ MC_1; // ACLK, up-down mode
_BIS_SR(LPM0_bits+GIE);
__enable_interrupt();
}
}
}
// __enable_interrupt();
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
//wait(10);
LPM0_EXIT; TACTL&=~OUTMOD_7;
}
//Wait a designated amount of time in milliseconds.
void wait(int ms)
{
volatile int i;
for(i=0; i<ms*3200; i++);
}