include <msp430g2231.h>
unsigned int flag = 0;void main(){ WDTCTL = WDTPW +WDTHOLD; //STOP WDT // FLL_CTL0 |= XCAP14PF; //匹配14PF的负载电容 P1SEL &= ~BIT5; P1DIR |= BIT5; TACTL = TASSEL1 + TACLR ; TACCTL0 = CCIE; TACCR0 = 1748; TACTL |= MC0; _EINT(); while (1) { LPM0; }}
# pragma vector = TIMERA0_VECTOR__interrupt void TimerA0_ISR(void){ P1OUT ^= BIT5; flag++;}
我用flag作为标志,发现并没有进入中断,为什么啊?哪里错了?
此帖出自
小平头技术问答
MC0 ----〉01
MC1 ----〉10
MC_0 —>00
MC_1 —>01
MC_2 —>10
MC_3 —>11
2231我试过了,程序没问题啊
#include “msp430g2231.h”
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1SEL &= ~BIT5;
P1DIR |= BIT5; // P1.5 output
TACTL = TASSEL1 + TACLR; // SMCLK, contmode
TACCTL0 = CCIE; // CCR0 interrupt enabled
TACCR0 = 1748;
TACTL |= MC0;
_EINT();
while (1)
{
LPM0;
} // Enter LPM0 w/ interrupt
}
// Timer A0 interrupt service routine
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
P1OUT ^= BIT5; // Toggle P1.0
}
可以进中断</msp430g2231.h>
[ 本帖最后由 juring 于 2012-7-10 19:22 编辑 ]
一周热门 更多>