定义中断服务程序
#pragma vector=PORT1_VECTOR //P1口中断向量
__interrupt void Port_1(void) //声明中断服务程序,名为Port_1
{
... //中断服务程序
}
定时器中断应用例程
#include <msp430.h>
void delay(unsigned int i)
{
volatile unsigned int j;
for(;i>0;i--)
for(j=0;j<2000;j++); // 延时
}
int main(void)
{
volatile unsigned int i ;
WDTCTL = WDTPW+WDTHOLD; // 关闭看门狗
P1DIR |= BIT0; // P1.0 输出
P4DIR |= BIT7; // P4.7 输出
TA0CCTL0 = CCIE; // CCR0中断使能
TA0CCR0 = 50000;
TA0CTL = TASSEL_2 + MC_1 +TACLR; // SMCLK,增计数模式,清除TAR<