msp430 launchPad 看门狗定时器操作
[复制链接]
设置msp430看门狗定时器32ms中断一次,让LED闪烁。
#include
void main(void)
{
WDTCTL = WDT_MDLY_32; // Set Watchdog Timer interval to ~30ms(WDTPW+WDTTMSEL+WDTCNTCL)
IE1 |= WDTIE; // Enable WDT interrupt
P1DIR |= (BIT0+BIT6); // Set P1.0,P1.6 to output direction
_BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
}
// Watchdog Timer interrupt service routine
#pragma vector=WDT_VECTOR
__interrupt void watchdog_timer(void)
{
P1OUT ^= (BIT0+BIT6); // Toggle P1.0 ,P1.6using exclusive-OR
}
|