TI中文支持网
TI专业的中文技术问题搜集分享网站

MSP430G2452

我写了个按键程序,我是初学者,希望能帮我看下。P1.0到P1.3口接LED,P2.7接独立按键。
我写的程序不知道为什么进不去定时器中断;
#include <msp430.h>
#define CPU_F ((double)1000000)//CPU主频 MCLK=32MHz#define delay_us(x) __delay_cycles((long)(CPU_F*(double)x/1000000.0)) //微秒#define delay_ms(x) __delay_cycles((long)(CPU_F*(double)x/1000.0)) //毫秒
void TimeA_init(void);
int i;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
if (CALBC1_1MHZ==0xFF)
{ // If calibration constant erased
while(1); // do not load, trap CPU!!
}

DCOCTL = 0; // Select lowest DCOx and MODx settings BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
BCSCTL1 |= DIVA_0;
BCSCTL3 |= LFXT1S_2;
P1DIR=0xff;
P1SEL=0X00;
P1OUT=0xf0;
P2OUT=0x80;
P2SEL=0X00;
P2DIR=0x7f;
TimeA_init();
while(1)
{
if((P2IN&0X80)!=0X80)
{
delay_ms(10);
if((P2IN&0X80)!=0X80)
{
CCTL0=CCIE;
if(i>100)
{
P1OUT|=BIT0;
i=0;
CCTL0&=~CCIE;
}
else{
P1OUT|=BIT1;
}
while((P2IN&0X80)!=0X80);
}
}
}}
void TimeA_init(void)
{
CCTL0&=~CCIE;
CCR0=50000;
TACTL=TASSEL_2 + MC_1;
}

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A (void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMER0_A0_VECTOR))) Timer_A (void)
#else
#error Compiler not supported!
#endif
{
i++;
}

jiayuan song:

来人回复一下啊

赞(0)
未经允许不得转载:TI中文支持网 » MSP430G2452
分享到: 更多 (0)