我想用TimerA0产生一个PWM波形,TimerA1控制它在三个周期后中断,程序如下:
#include <msp430g2553.h>
void main(void)
{
//unsigned char i=0;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= BIT2; // P1.2 and P1.3 output
P1SEL |= BIT2; // P1.2 and P1.3 TA1/2 options
while(1)
{
CCR0 = 512-1; // PWM Period
CCTL1 = OUTMOD_7; // CCR1 reset/set
CCR1 = 384; // CCR1 PWM duty cycle
TACTL = TASSEL_2 + MC_1; // SMCLK, up mode
CCTL0_ |= CCIE; //Open timeA1 IE
TACTL_ = TASSEL_2+MC_1;
CCR2_=1533;
_BIS_SR(CPUOFF); // Enter LPM0
}
}
#pragma vector=TIMER0_A1_VECTOR
__interrupt void Timer_A1(void)
{
P1OUT=0x00;
}
但是编译器提示我说Error[Pe137]: expression must be a modifiable lvalue C:\Users\roy\Desktop\New folder\CLK\main.c 39
我没有定义错啊 这个是怎么回事?
Hardy Hu:
CCTL0_ |= CCIE; //Open timeA1 IE
TACTL_ = TASSEL_2+MC_1;
CCR2_=1533;
这三句话中的左式寄存器名字多了一个下划线