郭天祥MSP430教程源码-LPM3.zip
时间:10-27 14:44
查看:1136次
下载:162次
简介:
有关郭天祥MSP430教程源码-LPM3实验程序设计。
#include <msp430x14x.h>
#include "BoardConfig.h"
void main(void)
{
BoardConfig(0xb8);
BCSCTL1 |= DIVA_2; // ACLK/4
WDTCTL = WDT_ADLY_1000; // WDT 1s/4 interval timer
IE1 |= WDTIE; // Enable WDT interrupt
P1DIR = 0xFF; // All P1.x outputs
P1OUT = 0; // All P1.x reset
P2DIR = 0xFF; // All P2.x outputs
P2OUT = 0; // All P2.x reset
P3DIR = 0xFF; // All P3.x outputs
P3OUT = 0x30; // All P3.x reset
P4DIR = 0xFF; // All P4.x outputs
P4OUT = 0; // All P4.x reset
P5DIR = 0xFF; // All P5.x outputs
P5OUT = 0; // All P5.x reset
P6DIR = 0xFF; // All P6.x outputs
P6OUT = 0x80; // All P6.x reset
while(1)
{
uint i;
_BIS_SR(LPM3_bits + GIE); // Enter LPM3
P3OUT &= ~BIT5; // Set P3.5 LED on
for (i = 18000; i>0; i--); // Delay
P3OUT |= BIT5; // Clear P3.5 LED off
}
}
#pragma vector=WDT_VECTOR
__interrupt void watchdog_timer (void)
{
_BIC_SR_IRQ(LPM3_bits); // Clear LPM3 bits from 0(SR)
}