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.

MSP432 软件方法怎么实现16位AD

MSP432 软件方法怎么实现16位AD

  • 可以从下载的软件包找到操作演示例子。

  • 给你提供一个参考,你下载后可以看到很多个ADC操作的示例

    /*
     * -------------------------------------------
     *    MSP432 DriverLib - v3_21_00_05 
     * -------------------------------------------
     *
     * --COPYRIGHT--,BSD,BSD
     * Copyright (c) 2016, 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.
     * --/COPYRIGHT--*/
    /*******************************************************************************
     * MSP432 ADC14 -  Single Channel with External Reference
     *
     * Description: This very simple code example shows the use of an external
     * reference for use in the ADC14 module. A single channel sample/conversion
     * is setup on input A0 (P5.5) and the sample timer is used to continuously
     * store the result in a local variable. The value coming in VREF+ (P5.6) is
     * treated as the max value of the ADC and the value coming in VREF- (P5.7) is
     * treated as the minimum value.
     *
     *                MSP432P401
     *             ------------------
     *         /|\|                  |
     *          | |                  |
     *          --|RST         P5.5  |<---- A0 In
     *            |            P5.6  |<---- VREF+
     *            |            P5.7  |<---- VREF-
     *            |                  |
     *
     * Author: Timothy Logan
     ******************************************************************************/
    /* DriverLib Includes */
    #include "driverlib.h"
    
    /* Standard Includes */
    #include <stdint.h>
    
    #include <string.h>
    
    volatile uint16_t adcResult;
    
    int main(void)
    {
        /* Halting WDT */
        WDT_A_holdTimer();
        Interrupt_enableSleepOnIsrExit();
        
        /* Initializing ADC (MCLK/1/1) */
        ADC14_enableModule();
        ADC14_initModule(ADC_CLOCKSOURCE_MCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_1,
                0);
    
        /* Configuring ADC Memory (ADC_MEM0 A0/A1) in repeat mode
         * with use of external references */
        ADC14_configureSingleSampleMode(ADC_MEM0, true);
        ADC14_configureConversionMemory(ADC_MEM0, ADC_VREFPOS_EXTPOS_VREFNEG_EXTNEG,
                ADC_INPUT_A0, false);
    
        /* Setting up GPIO pins as analog inputs (and references) */
        GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5,
                GPIO_PIN7 | GPIO_PIN6 | GPIO_PIN5 | GPIO_PIN4, GPIO_TERTIARY_MODULE_FUNCTION);
    
        /* Enabling sample timer in auto iteration mode and interrupts*/
        ADC14_enableSampleTimer(ADC_AUTOMATIC_ITERATION);
        ADC14_enableInterrupt(ADC_INT0);
    
        /* Enabling Interrupts */
        Interrupt_enableInterrupt(INT_ADC14);
        Interrupt_enableMaster();
    
        /* Triggering the start of the sample */
        ADC14_enableConversion();
        ADC14_toggleConversionTrigger();
    
        /* Going to sleep */
        while (1)
        {
            PCM_gotoLPM0();
        }
    }
    
    /* This interrupt happens whenever a conversion has been completed and placed
     * into ADC_MEM0. */
    void ADC14_IRQHandler(void)
    {
        uint64_t status;
    
        status = ADC14_getEnabledInterruptStatus();
        ADC14_clearInterruptFlag(status);
    
        if(status & ADC_INT0)
        {
            adcResult = ADC14_getResult(ADC_MEM0);
        }
    
    }
    

  • 建议您看一下相关的APP NOTE: Precision ADC With 16-Bit Performance

     给出了相关的测试代码。

  • 这只有14位吧?
  • 谢谢,知道怎么回事了
  • 很高兴您能解决问题!