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

msp430g2x11 ca 02

1 132 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,54 KB

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

Nội dung

// Using an external potentiometer, an unknown voltage is applied to P1.1.. // Comparator_A compares the unknown voltage to an internal reference // voltage, in this example 0.25*VCC.. D

Trang 1

//****************************************************************************** // MSP430G2x11 Demo - Comp_A, Detect Threshold, Set P1.0 if P1.1 > 0.25*Vcc //

// Description: Use Comparator_A to detect a voltage threshold

// Using an external potentiometer, an unknown voltage is applied to P1.1 // Comparator_A compares the unknown voltage to an internal reference

// voltage, in this example 0.25*VCC If the unknown voltage is higher

// than 0.25*VCC, P1.0 is set, if not, P1.0 is reset

// ACLK = n/a, MCLK = SMCLK = default DCO

//

// MSP430G2x11

//

-// /|\ |

XIN|-// | | |

// -|RST

XOUT|-// | | |

// R<-|P1.1/CA1 P1.0| >LED

// | | |

// -|VSS

//

// D Dang

// Texas Instruments Inc

// October 2010

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

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

#include <msp430g2211.h>

void main (void)

{

WDTCTL = WDTPW + WDTHOLD; // Stop WDT

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

CACTL1 = CARSEL + CAREF0 + CAON; // 0.25 Vcc = -comp, on

CACTL2 = P2CA4; // P1.1/CA1 = +comp

while (1) // Test comparator_A output

{

if ((CAOUT & CACTL2))

P1OUT |= 0x01; // if CAOUT set, set P1.0

else P1OUT &= ~0x01; // else reset

}

}

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

TỪ KHÓA LIÊN QUAN

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

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

TÀI LIỆU LIÊN QUAN

w