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作为标志,发现并没有进入中断,为什么啊?哪里错了?
此帖出自
小平头技术问答
#include <msp430g2553.h>
void main(void){ WDTCTL = WDTPW + WDTHOLD; // Stop WDT P1DIR |= BIT0; // P1.0 output CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = 50000; TACTL = TASSEL1 + TACLR + MC_2; //TACTL = TASSEL_2 + MC_2; // SMCLK, contmode
_BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt}
// Timer A0 interrupt service routine#pragma vector=TIMER0_A0_VECTOR__interrupt void Timer_A (void){ P1OUT ^= BIT0; // Toggle P1.0 CCR0 += 50000; // Add Offset to CCR0}
这个不是增计数模式吗?
这不是增计数模式吗?
同学~
一周热门 更多>