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

msp430g2xx2 ta 04

1 138 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 1
Dung lượng 1,63 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

// In this example an ISR triggers when TA overflows.. Toggle rate is exactly 0.5Hz.. Proper use of the TA0IV interrupt // vector generator is demonstrated.. Dang // Texas Instruments In

Trang 1

//****************************************************************************** // MSP430G2xx2 Demo - Timer_A, Toggle P1.0, Overflow ISR, 32kHz ACLK

//

// Description: Toggle P1.0 using software and the Timer_A overflow ISR

// In this example an ISR triggers when TA overflows Inside the ISR P1.0

// is toggled Toggle rate is exactly 0.5Hz Proper use of the TA0IV interrupt // vector generator is demonstrated

// ACLK = TACLK = 32768Hz, MCLK = SMCLK = default DCO

// //* An external watch crystal on XIN XOUT is required for ACLK *//

//

// MSP430G2xx2

//

-// /|\|

XIN|-// | | | 32kHz

// |RST

XOUT|-// | |

// | P1.0| >LED

//

// D Dang

// Texas Instruments Inc

// December 2010

// Built with CCS Version 4.2.0 and IAR Embedded Workbench Version: 5.10

//******************************************************************************

#include <msp430g2452.h>

void main(void)

{

WDTCTL = WDTPW + WDTHOLD; // Stop WDT

P1DIR |= 0x01; // P1.0 output

TACTL = TASSEL_1 + MC_2 + TAIE; // ACLK, contmode, interrupt

_BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/ interrupt

}

// Timer_A3 Interrupt Vector (TA0IV) handler

#pragma vector=TIMER0_A1_VECTOR

interrupt void Timer_A(void)

{

switch( TA0IV )

{

case 2: break; // CCR1 not used

case 4: break; // CCR2 not used

case 10: P1OUT ^= 0x01; // overflow

break;

}

}

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

TỪ KHÓA LIÊN QUAN

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

TÀI LIỆU LIÊN QUAN

w