|
#include
void BreathLED()
{
P1SEL =BIT6;
P1DIR = BIT6;
P1OUT=0;
TACTL = TASSEL_1 + MC_1 ;
TACCTL1 = OUTMOD_3 ;
TACCTL0 = CCIE;
CCR0 =12000;
CCR1 =327; //0% pwm
TACTL |=TACLR;
_EINT();
}
int main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
BCSCTL3 |= LFXT1S_2; // Set LFXT1为vol时钟即12kHZ
BreathLED();
LPM0;
return 0;
}
#pragma vector=TIMER0_A0_VECTOR
__interrupt void CountTimes()
{
static int Times;
Times++;
switch(Times)
{
case 20:
CCR1=294;
break;
case 30:
CCR1=277;
break;
case 40:
CCR1=262; //20% PWM
break;
case 50:
CCR1=245; //20% PWM
break;
case 60:
CCR1=228; //40% PWM
break;
case 80:
CCR1=196; //40% PWM
break;
case 100:
CCR1=163;
break;
case 120:
CCR1=131; //60% PWM
break;
case 140:
CCR1=98; //60% PWM
break;
case 160:
CCR1=65; //80% PWM
break;
case 180:
CCR1=32; //80% PWM
break;
case 200:
CCR1=1; //100% PWM
break;
case 220:
CCR1=32; //80% PWM
break;
case 240:
CCR1=65;
break;
case 260:
CCR1=98; //60% PWM
break;
case 280:
CCR1=131;
break;
case 300:
CCR1=163;
break;
case 320:
CCR1=196;
break;
case 340:
CCR1=228; //40% PWM
break;
case 350:
CCR1=245; //40% PWM
break;
case 360:
CCR1=262;
break;
case 370:
CCR1=277;
break;
case 380:
CCR1=294;
break;
case 390:
CCR1=310;
break;
case 400:
{
CCR1=327;
Times=0;
}
break;
default:
break;
}
}
|
|