#include "msp430g2553.h"
int main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
P1DIR |= BIT0;
P1OUT &= ~BIT0;
CCR0=50000;
TACTL=TAIE+TASSEL_2+MC_1;
while(1);
//return 0;
}
#pragma vector=TIMER0_A0_VECTOR
__interrupt void timer_A(void)
{
P1OUT |= BIT0;
}
P1.0有个灯,最开始我是让他闪烁的,后来发现没进入中断,所以中断函数里面就写了个让他亮的程序,但是一直没亮,所以没进入中断,我不知道问题出在哪儿,请各位坛友帮我看下
此帖出自
小平头技术问答
- #include
- void main(void)
- {
- WDTCTL = WDTPW + WDTHOLD; // Stop WDT
- P1DIR |= 0x01; // P1.0 output
- CCTL1 = CCIE; // CCR1 interrupt enabled
- CCR1 = 50000;
- TACTL = TASSEL_2 + MC_2; // SMCLK, Contmode
- _BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
- }
- // Timer_A3 Interrupt Vector (TA0IV) handler
- #pragma vector=TIMER0_A1_VECTOR
- __interrupt void Timer_A(void)
- {
- switch( TA0IV )
- {
- case 2: // CCR1
- {
- P1OUT ^= 0x01; // Toggle P1.0
- CCR1 += 50000; // Add Offset to CCR1
- }
- break;
- case 4: break; // CCR2 not used
- case 10: break; // overflow not used
- }
- }
复制代码一周热门 更多>