我写了一段需要调用中断的程序,可是中断没有被执行,大家帮忙看看是怎么回事。
#include <msp430f4250.h>
#include <stdlib.h>
#include <math.h>
int count;
void main(void)
{
int i;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
FLL_CTL0 |= XCAP14PF; // Configure load caps
P1DIR |= BIT2;//设置P1口为输出状态;
P1SEL |= BIT2;
for (i = 0x0000; i < 0x3600; i++); // Delay for 1.2V ref startup
for (i =0; i < 10000; i++); // Delay for 32 kHz crystal to
CCR0 = 512-1; // PWM Period
CCTL1 = OUTMOD_7; // CCR1 reset/set
CCR1 = 511; // CCR1 PWM duty cycle // CCR2 PWM duty cycle
TACTL = TASSEL_1 + MC_1; // ACLK, up mode
__enable_interrupt(); // Enable general interrupts
for(;;)
{
count=1200;
if(count>0)
for(;count>0;)
{
TACCTL0 |= CCIE;//这里是开分中断,预想中执行此中断的时候,count的值要减1,可是实际执行的时候,count的值始终不变
CCR1=511;
}
}
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMERA0_VECTOR))) Timer_A (void)
#else
#error Compiler not supported!
#endif
{
if(count>0)
{
--count;
}
else{
__bic_SR_register_on_exit(LPM0_bits);
}
} |