#include "msp430f5529.h"
#define uchar unsigned char
#define uint unsigned int
void main( void )
{
// Stop watchdog
timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD;
P1DIR |=BIT3+BIT1+BIT4; P1OUT=BIT1+BIT3+BIT4;
TA0CCR0=32768-1;//1秒
TA0CCR1=6554;//0.2秒
TA0CCR2=29938;//0.7秒 TA0CTL=TASSEL_1+MC_1;
TA0CTL |=TAIE; //允许TA溢出中断 TA0CCTL1=CCIE;//CCR0使能中断允许 TA0CCTL2=CCIE; __bis_SR_register(LPM0_bits+GIE);
}
#pragma vector=TIMER0_A0_VECTOR
__interrupt void TIMER0_A0_ISR(void)
{
switch(__even_in_range(TA1IV,10))
{
case 0: break;
case 2: P1OUT &=~(BIT1+BIT3+BIT4); P1OUT |=BIT1;
P1OUT=~P1OUT;
break;
case 4: P1OUT &=~(BIT1+BIT3+BIT4); P1OUT |=BIT4;
P1OUT=~P1OUT;
break;
case 6:break;
case 8:break;
case 10: P1OUT &=~(BIT1+BIT3+BIT4); P1OUT |=BIT3;
P1OUT=~P1OUT;
break;
default:break;
}
}
//请问这个程序为什么不能实现3个端口的led灯按一定的时间闪烁?
一周热门 更多>