MSP430F169看门狗程序
作者:互联网
MSP430F169看门狗程序
- 看门狗用作定时器,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
}
- 看门狗用作定时器,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
}
- 看门狗用作定时器,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
}
标签:void,程序,0x01,timer,MSP430F169,WDT,interrupt,看门狗 来源: https://www.cnblogs.com/guochaoxxl/p/14604104.html