请问大佬们,我又两个问题,ADC中ADC12REF2_5v和ADC12SREF中选择参考电压源选择位,这两者是什么关系?
ADC里可以设置外部电压为参考电压,外部电压在哪个引脚输入,外部电压有没有限制?
谢谢大佬们!!!!!! 爱你们哦!!!!
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
请问大佬们,我又两个问题,ADC中ADC12REF2_5v和ADC12SREF中选择参考电压源选择位,这两者是什么关系?
ADC里可以设置外部电压为参考电压,外部电压在哪个引脚输入,外部电压有没有限制?
谢谢大佬们!!!!!! 爱你们哦!!!!
ADC12REF2_5是内部基准源电压选择位。选择该位的时候,必须置位REFON
ADC12SREFX是参考源选择位
使用内部参考电压的话,您需要打开参考源,选择ADC12SREF_1 即为内部基准参考源,然后需要使能 REFON,最后选择参考电压ADC12REF2_5 1.5V or 2.5V)
建议您结合例程看一下
/* --COPYRIGHT--,BSD_EX
* Copyright (c) 2012, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*******************************************************************************
*
* MSP430 CODE EXAMPLE DISCLAIMER
*
* MSP430 code examples are self-contained low-level programs that typically
* demonstrate a single peripheral function or device feature in a highly
* concise manner. For this the code may rely on the device's power-on default
* register values and settings such as the clock configuration and care must
* be taken when combining code from several examples to avoid potential side
* effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
* for an API functional library-approach to peripheral configuration.
*
* --/COPYRIGHT--*/
//******************************************************************************
// MSP430F552x Demo - ADC12, Using the Internal Reference
//
// Description: This example shows how to use the internal reference of REF
// module using the ADC12 control registers.
// The ADC12 uses the internal 2.5V reference and performs a single conversion
// on channel A0. The conversion results are stored in ADC12MEM0. Test by
// applying a voltage to channel A0, then setting and running to a break point
// at the "__no_operation()" instruction. To view the conversion results,
// open an ADC12 register window in debugger and view the contents of ADC12MEM0
//
// NOTE:REFMSTR bit in REFCTL0 regsiter is reset to allow the ADC12_A reference
// control regsiters handle the reference setting. Upon resetting the REFMSTR
// bit, all the settings in REFCTL are 'dont care' and the legacy ADC12
// control bits (ADC12REFON, ADC12REF2_5, ADC12TCOFF and ADC12REFOUT) control
// the reference system.
//
// MSP430F552x
// -----------------
// /|\| |
// | | |
// --|RST |
// | |
// Vin -->|P6.0/CB0/A0 |
// | |
//
// Bhargavi Nisarga
// Texas Instruments Inc.
// April 2009
// Built with CCSv4 and IAR Embedded Workbench Version: 4.21
//******************************************************************************
#include <msp430.h>
int main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P6SEL |= 0x01; // Enable A/D channel A0
REFCTL0 &= ~REFMSTR; // Reset REFMSTR to hand over control to
// ADC12_A ref control registers
ADC12CTL0 = ADC12ON+ADC12SHT02+ADC12REFON+ADC12REF2_5V;
// Turn on ADC12, Sampling time
// On Reference Generator and set to
// 2.5V
ADC12CTL1 = ADC12SHP; // Use sampling timer
ADC12MCTL0 = ADC12SREF_1; // Vr+=Vref+ and Vr-=AVss
for ( i=0; i<0x30; i++); // Delay for reference start-up
ADC12CTL0 |= ADC12ENC; // Enable conversions
while (1)
{
ADC12CTL0 |= ADC12SC; // Start conversion
while (!(ADC12IFG & BIT0));
__no_operation(); // SET BREAKPOINT HERE
}
}