msp430xg46x_oa_04.c

来自「MSP430FG461x.zip c语言 例程打包」· C语言 代码 · 共 43 行

C
43
字号
//*****************************************************************************
//  MSP430xG46x Demo - OA0, Inverting PGA Mode
//
//  Description: Configure OA0 for Inverting PGA mode. In this mode, the
//  "+" terminal must be supplied with an offset, since the OA is a
//  single-supply opamp, and the input must be positive. If an offset is
//  not supplied, the opamp will try to drive its output negative, which
//  cannot be done. In this example, the offset is provided by DAC0 and
//  is 1.5V. The "-" terminal is connected to the R ladder tap and the
//  OAFBRx bits select the gain. The input signal should be AC coupled.
//  ACLK = 32.768kHz, MCLK = SMCLK = default DCO
//
//                    MSP430xG461x
//                -------------------
//            /|\|                XIN|-
//             | |                   |
//             --|RST            XOUT|-
//               |                   |
//    "-" --||-->|P6.0/OA0I0         |
//               |                   |
//               |          P6.1/OA0O|->  OA0 Output
//               |                   |    Gain is -7
//
// 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;                      // Offset level = 1.5V

  OA0CTL0 = OAP_2 + OAPM_1 + OAADC1;        // Select inputs, power mode
  OA0CTL1 = OAFC_6 + OAFBR_6 + OARRIP;      // Mode, OAFBRx sets gain

  _BIS_SR(LPM3_bits + GIE);                 // LPM3
}

⌨️ 快捷键说明

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