|
定义了全局变量,在中断函数中赋值。在主程序中全局变量的值为何没有变。请各位大侠指教,不胜感激!结果是 ser=0!!!!!
#include <msp430x14x.h>
unsigned char a[6];
unsigned char b[6];
unsigned char n;
unsigned char pt;
unsigned char ser;
unsigned char flag;
void main(void)
{
unsigned char i;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
TBCTL = TBSSEL_1 + TBCLR; // ACLK, clear TBR
TBCCTL0 = CCIE; // TRCCR0 interrupt ena××ed
TBCCR0 = 1000-1;
TBCTL = TBSSEL_1 + MC_1;
_EINT();
if (flag==1)
ser=a[3]+a[4];
}
#pragma vector=TIMERB0_VECTOR
__interrupt void Timer_B (void)
{
a[pt]=n;
pt++;
n++;
if (pt==6)
{
flag=1;
TBCCTL0 &=~CCIE;//禁止中断。
}
}
|
|