首页 > 其他 > 详细

MSP430F169看门狗程序

时间:2021-04-01 00:10:51      阅读:49      评论:0      收藏:0      [点我收藏+]

MSP430F169看门狗程序

  1. 看门狗用作定时器,DCO
#include <msp430f169.h>

int main(void)
{
    WDTCTL = WDT_MDLY_32;                   // Set Watchdog Timer interval to ~30ms
    IE1 |= WDTIE;                           // Enable WDT interrupt
    P6DIR |= 0x01;                          // Set P6.0 to output direction

    _EINT();
    LPM0;                                   // Enter LPM0 w/ interrupt
}

// Watchdog Timer interrupt service routine
#pragma vector=WDT_VECTOR
__interrupt void watchdog_timer(void){
    P6OUT ^= 0x01;                         // Toggle P6.0 using exclusive-OR
}
  1. 看门狗用作定时器,ACLK
#include <msp430f169.h>

int main(void)
{
    WDTCTL = WDT_ADLY_250;                    // WDT 250ms, ACLK, interval timer
    IE1 |= WDTIE;                             // Enable WDT interrupt
    P6DIR |= 0x01;                            // Set P1.0 to output direction

    _EINT()
    LPM3;                                     // Enter LPM3 w/interrupt
}

// Watchdog Timer interrupt service routine
#pragma vector=WDT_VECTOR
__interrupt void watchdog_timer(void)
{
    P6OUT ^= 0x01;                            // Toggle P1.0 using exclusive-OR
}
  1. 看门狗用作定时器,XT2CLK
#include <msp430f169.h>

int main(void)
{
    volatile unsigned int i;
    WDTCTL = WDT_ADLY_16;                     // ACLK / 512, interval timer
    BCSCTL1 |= XTS;                           // ACLK = LFXT1 = HF XTAL

    do
    {
        IFG1 &= ~OFIFG;                       // Clear OSCFault flag
        for (i = 0xFF; i > 0; i--)
            ;                                 // Time for flag to set
    }
    while ((IFG1 & OFIFG));                   // OSCFault flag still set?

    BCSCTL2 |= SELM_3;                        // MCLK = LFXT1 (safe)
    IE1 |= WDTIE;                             // Enable WDT interrupt
    P6DIR |= 0x01;                            // Set P1.0 to output direction

    _EINT();
    LPM0;                                     // Enter LPM0 w/ interrupt
}

// Watchdog Timer interrupt service routine
#pragma vector=WDT_VECTOR
__interrupt void watchdog_timer(void)
{
    P6OUT ^= 0x01;                            // Toggle P1.0 using exclusive-OR
}

MSP430F169看门狗程序

原文:https://www.cnblogs.com/guochaoxxl/p/14604104.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!