fet430_oa1_comp_02.c

来自「msp430F435做的医疗器械,包括语音模块,知识源于网络」· C语言 代码 · 共 40 行

C
40
字号
//******************************************************************************
//   MSP-FET430P430 Demo - OA1 Used As A Comparator In General-Purpose Mode
//
//   Description; Use OA1 of the MSP430FG439 as a comparator in general-
//   purpose mode. In this example, the OA1 is configured in general-purpose
//   mode, but used as a comparator. The reference is supplied by DAC12_0 on
//   the - input. The + terminal is connected to the OA1I0 signal at the pin.
//   //* MSP430FG439 Device Required*//
// 
//                MSP430FG439
//             -------------------
//         /|\|                XIN|-  
//          | |                   |
//          --|RST            XOUT|-
//            |                   |
//            |      P6.4/A4/OA1I0|<-  Input
//            |       P6.3/A3/OA1O|->  OA1 Output
//            |                   |
//
//   M.Mitchell
//   Texas Instruments, Inc
//   April 2004
//   Built with IAR Embedded Workbench Version: 2.21B
//******************************************************************************
#include  <msp430xG43x.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.5 V
  
  OA1CTL0 = OAN_2 + OAPM_1;             // Select inputs, power mode
  OA1CTL1 = OARRIP;                     // Mode, rail-to-rail input
  
  LPM3;                                 // LPM3
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?