📄 msp430x24x_compa_04.c
字号:
//******************************************************************************
// MSP430x24x Demo - Comparator A, Poll input CA0, result in P1.0
//
// Description: The voltage at pin CA0 (Vcompare) is compared with reference
// voltage of diode ref. LED is toggled when Vcompare crosses the ref voltage.
//
// MSP430F249
// -----------------
// /|\| |
// | | |
// --|RST P2.3/CA0|<--Vcompare
// | |
// | P1.0|-->CAOUT - LED
//
// B. Nisarga
// Texas Instruments Inc.
// September 2007
// Built with IAR Embedded Workbench Version: 3.42A
//******************************************************************************
#include <msp430x24x.h>
void main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop WDT
CACTL1 = CAON+CAREF_3+CARSEL; //Enable comp, ref = Diode ref
CACTL2 = P2CA0; // Pin to CA0
P1DIR |= 0x001; // P1.0 = o/p direction (CAOUT- LED)
P1SEL |= 0x001; // P1.0 - CAOUT, option select
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -