|
#include "msp430g2553.h"
//unsigned char SPWM_FLAG;
unsigned char i=0;
void main(void)
{
//unsigned char i=0;
//unsigned char a[32]={0x80,0x98,0xb0,0xc6,0xda,0xea,0xf5,0xfd,0xff,0xfd,0xf5,0xea,0xda,0xc6,0xb0,0x98,0x7f,0x67,0x4f,0x39,0x25,0x15,0x0a,0x02,0x00,0x02,0x0a,0x15,0x25,0x39,0x4f,0x67};
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P2DIR |= 0x22; // P1.2 and P1.3 output
P2SEL |= 0x22; // P1.2 and P1.3 TA1/2 options
TA1CCR0 = 0x0ff; // PWM Period
TA1CCTL0 = CCIE; // CCR0 interrupt enabled
TA1CCTL1 = OUTMOD_2; // CCR1 reset/set
TA1CCTL2 = OUTMOD_2; // CCR1 PWM duty cycle
TA1CTL = TASSEL_2 + MC_1;// SMCLK, up mode
TA1CCR1=0X80;
TA1CCR2=0X5F;
_BIS_SR(LPM0_bits+GIE);
}
#pragma vector=TIMER1_A0_VECTOR
__interrupt void TIMER1_A0_ISR(void)
{
// unsigned char i=0;
unsigned char a[32]={0x80,0x98,0xb0,0xc6,0xda,0xea,0xf5,0xfd,0xff,0xfd,0xf5,0xea,0xda,0xc6,0xb0,0x98,0x7f,0x67,0x4f,0x39,0x25,0x15,0x0a,0x02,0x00,0x02,0x0a,0x15,0x25,0x39,0x4f,0x67};
TA1CCR1=a;
TA1CCR2 =a[31-i];
if(i==31)
i=0;
else
i++;
}
欢迎大家拍砖学习
|
|