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.

MSP430F4250选用A2通道要怎么配置的问题

Other Parts Discussed in Thread: MSP430F4250, MSP430F4270

MSP430F4250的A2通道是差分输入ADC通道,被分配到P1.7,P1.6端口,我想使用A2通道应该怎么配置呢?

msp430f4250.pdf
  • 和使用其他通道基本是一样的

    下面是一个使用通道5的例程

    /* --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--*/
    //*****************************************************************************
    // MSP430x42x0 Demo - SD16_A, Using the Integrated Battery Sensor
    //
    // Description: This example shows how to use the SD16_A module's integrated
    // Battery sensor (connected to input channel 5) to measure VCC.
    // A single conversion is initiated and then the CPU is disabled by entering
    // LPM0. Once the conversion has completed, a SD16_A interrupt occurs and
    // stores the result in variable "ADCresult". LED lights if batter is low
    // ACLK = LFXT1 = 32768 Hz, MCLK = SMCLK = DCO = 32 x ACLK = 1048576 Hz
    // //* An external watch crystal on XIN XOUT is required for ACLK *//
    // //* Minimum Vcc is required for SD16_A module - see datasheet *//
    // //* 100nF cap btw Vref and AVss is recommended when using 1.2V ref *//
    //
    // MSP430F4270
    // -----------------
    // /|\| XIN|-
    // | | | 32kHz
    // --|RST XOUT|-
    // | |
    // |A5+ | ( A5+, A5- connected internally )
    // |A5- |
    // | |
    // | VREF |---+
    // | | |
    // | | -+- 100nF
    // | | -+-
    // | | |
    // | AVss |---+
    // | |
    //
    // L. Westlund / S. Karthikeyan
    // Texas Instruments Inc.
    // June 2005
    // Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.30A
    //*****************************************************************************
    #include <msp430.h>

    #define LOW_BAT 0xBFFF // ~3V

    static unsigned int ADCresult;

    int main(void)
    {
    volatile unsigned int i; // Use volatile to prevent removal
    // by compiler optimization
    P1DIR |= 0x01;

    WDTCTL = WDTPW + WDTHOLD; // Stop WDT
    FLL_CTL0 |= XCAP14PF; // Configure load caps
    for (i = 0; i < 10000; i++); // Delay for 32 kHz crystal to
    // stabilize

    SD16CTL = SD16REFON+SD16SSEL0; // 1.2V ref, SMCLK
    SD16CCTL0 |= SD16SNGL+SD16IE ; // Single conv, enable interrupt
    SD16INCTL0 |= SD16INCH_5; // Select Channel A5
    for (i = 0; i < 0x3600; i++); // Delay for 1.2V ref startup

    __enable_interrupt(); // Enable general interrupts

    while (1)
    {
    SD16CCTL0 |= SD16SC; // Set bit to start conversion
    __bis_SR_register(LPM0_bits); // Enter LPM0
    if( ADCresult < LOW_BAT )
    {
    P1OUT |= 0x01;
    }
    else
    {
    P1OUT &= ~0x01;
    }
    __no_operation(); //SET BREAKPOINT HERE
    }
    }

    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=SD16_VECTOR
    __interrupt void SD16ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(SD16_VECTOR))) SD16ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
    switch (SD16IV)
    {
    case 2: // SD16MEM Overflow
    break;
    case 4: // SD16MEM0 IFG
    ADCresult = SD16MEM0; // Save results (clears IFG)
    break;
    }

    __bic_SR_register_on_exit(LPM0_bits); // Exit LPM0
    }

  • 谢谢您的程序,不过我已经找到问题的所在了,虽然说都是AD转换通道,但是对于MSP430F4250来说,它的AD通道的配置不全是一样的

  • dongwei fu 说:

    谢谢您的程序,不过我已经找到问题的所在了,虽然说都是AD转换通道,但是对于MSP430F4250来说,它的AD通道的配置不全是一样的

    是的 4250的是 16位 高精度 Sigma Delta ADC