#ifndef WDT_H_
#define WDT_H_
#include <msp430.h>
void WDT_init()
{
WDTCTL=WDT_ADLY_250; //250ms
SFRIE1 |= WDTIE; //WDT使能
_enable_interrupts(); // 总中断
//_bis_SR_register(LPM0_bits + GIE); // Enter LPM0, enable interrupts
}
#pragma vector=WDT_VECTOR
__interrupt void WDT_ISR(void)
{
P1OUT ^= BIT0;
}
#endif /* WDT_H_ */
#include <msp430.h>
#include "TA0.h"
#include "TA0_PWM.h"
#include "WDT.h"
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
TA0_Init();//初始化TA0
WDT_init(); //看门狗定时器初始化
P1DIR|=BIT0;
} |