1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

msp430g2xx1 LFxtal nmi

2 93 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 2
Dung lượng 2,43 KB

Nội dung

//****************************************************************************** // MSP430G2xx1 Demo - LFXT1 Oscillator Fault Detection // // Description: System runs normally in LPM3 with WDT timer clocked by // 32kHz ACLK with a 1x4 second interrupt P1.0 is normally pulsed every // second inside WDT interrupt If an LFXT1 oscillator fault occurs, // NMI is requested forcing exit from LPM3 P1.0 is toggled rapidly by software // as long as LFXT1 oscillator fault is present Assumed only LFXT1 as NMI // source - code does not check for other NMI sources // ACLK = LFXT1 = 32768, MCLK = SMCLK = Default DCO // // //*External watch crystal on XIN XOUT is required for ACLK*// // // // MSP430G2xx1 // // /|\| XIN|// | | | 32kHz // |RST XOUT|// | | // | P1.0| >LED // // D Dang // Texas Instruments Inc // October 2010 // Built with CCS Version 4.2.0 and IAR Embedded Workbench Version: 5.10 //****************************************************************************** #include volatile unsigned int i; void main(void) { WDTCTL = WDT_ADLY_1000; IE1 |= WDTIE; P1DIR = 0xFF; P1OUT = 0; P2DIR = 0xFF; P2OUT = 0; // An immedate Osc Fault will occur next IE1 |= OFIE; while(1) { P1OUT ^= 0x01; _BIS_SR(LPM3_bits + GIE); } // // // // // // WDT 1s interval timer Enable WDT interrupt All P1.x outputs All P1.x reset All P2.x outputs All P2.x reset // Enable Osc Fault // Toggle P1.0 using exclusive-OR // Enter LPM3 w/interrupt } #pragma vector=WDT_VECTOR interrupt void watchdog_timer (void) { _BIC_SR_IRQ(LPM3_bits); } #pragma vector=NMI_VECTOR interrupt void nmi_ (void) { { IFG1 &= ~OFIFG; for (i = 0xFFF; i > 0; i ); P1OUT ^= 0x01; // Clear LPM3 bits from 0(SR) // Clear OSCFault flag // Time for flag to set // Toggle P1.0 using exclusive-OR } } while (IFG1 & OFIFG); IE1 |= OFIE; // OSCFault flag still set? // Enable Osc Fault

Ngày đăng: 26/12/2017, 07:48

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN

w