LunchPad MCU MSP430G2452 写了段程序学习,IAR 6.5版本,用看门狗中时间中断, 中断始终没有触发,是否可以帮忙看一下,谢谢
程序如下
#include "io430.h"
#include "io430g2452.h"
unsigned char const led_tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};//共阴数码管编码表
void Delay(int t)
{
int i;
while (t--)
for(i=500;i>0;i--);
}
int main( void )
{
int p;
p=0;
WDTCTL = WDT_ADLY_16;// 设置内部看门狗工作在定时器模式,1.6ms中断
IE1|= WDTIE; // 使能看门狗中断
P1SEL = 0X00;
P1DIR |= 0xFF; //定义P1为输出方向,端口1用来驱动LED共阴极数码管
P1OUT = 0x00; //定义P1输出为 0 ,
P2OUT =0xF7;
P2DIR |=(BIT0+BIT1+BIT2+BIT3+BIT5+BIT6+BIT7);
P2DIR &= ~BIT4; //先把BIT3 取反后和P1DIR与 P1DIR=PIDIR & ~BIT3
while(1)
{
p++;
if (p>=15000) p=0;
}
}
#pragma vector = WDT_VECTOR
__interrupt void Watchdog_timer(void)
{
int n;
for(n=0;n<10;n++)
P1OUT=led_tab[n];
Delay(600);
if(n>=9) P2OUT =0xF3;
Delay(600);
} |