📄 msp430xg46x_oa_02.c
字号:
//*****************************************************************************
// MSP430xG46x Demo - OA0, Comparator in General-Purpose Mode
//
// Description: Use OA0 as a comparator in general-purpose mode. In this
// example, OA0 is configured for general-purpose mode, but used as a
// comparator. The reference is supplied by DAC12_0 on the "-" input.
// The "+" terminal is connected to OA0I0.
// ACLK = 32.768kHz, MCLK = SMCLK = default DCO
//
// MSP430xG461x
// -------------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | |
// "+" -->|P6.0/OA0I0 |
// | |
// | P6.1/OA0O|--> OA0 Output
// | | Output goes high when
// | | Input > 1.5V
//
// K. Quiring/ M. Mitchell
// Texas Instruments Inc.
// October 2006
// Built with IAR Embedded Workbench Version: 3.41A
//*****************************************************************************
#include <msp430xG46x.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
ADC12CTL0 = REFON + REF2_5V; // Reference = 2.5V for DAC0
DAC12_0CTL = DAC12IR + DAC12AMP_2 + DAC12ENC;
DAC12_0DAT = 0x099a; // Reference level = 1.5V
OA0CTL0 = OAN_2 + OAPM_1; // Select inputs, power mode
OA0CTL1 = OARRIP; // Mode, rail-to-rail input
_BIS_SR(LPM3_bits + GIE); // LPM3
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -