1.看门狗产生方波
#include <msp430x14x.h>
void main()
{
WDTCTL = WDT_MDLY_32;
IE1 |= WDTIE;
P1DIR |= BIT1;
_EINT();
}
#pragma vector=WDT_VECTOR
__interrupt void Watchdog(void)
{
P1OUT ^= BIT1;
}
2.增计数模式
#include <msp430x14x.h>
void main()
{
WDTCTL = WDTPW + WDTHOLD;
P1DIR |= BIT1;
CCTL0 = CCIE;
CCR0 = ;
TACTL = TASSEL_2 + MC_1 + ID_3;
_EINT();
}
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A(void)
{
P1OUT ^= BIT1;
}
3.连续模式
#include <msp430x14x.h>
void main()
{
WDTCTL = WDTPW + WDTHOLD;
P1DIR |= BIT1;
TACTL = TASSEL_2 + MC_2 + ID_3 + TACLR + TAIE;
_EINT();
}
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A(void)
{
switch(TAIV)
{
case :break;
case :break;
case :P1OUT ^= BIT1;break;
}
}
4.增计数与连续模式
#include <msp430x14x.h>
void main()
{
WDTCTL = WDTPW + WDTHOLD;
P6DIR = 0xff;
P6OUT = 0XFF; TACCTL0= CCIE;
TACCR0 = ; TACTL = TASSEL_2 + MC_2 + ID_3 + TACLR + TAIE;
_EINT();
} #pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A0(void)
{
P6OUT = ~(P6OUT & BIT0);
TACCR0 = TACCR0 + ;
} #pragma vector=TIMERA1_VECTOR
__interrupt void Timer_A1(void)
{
switch(TAIV)
{
case :break;
case :break;
case :P6OUT = ~(P6OUT & BIT7);break;
}
}