请问TI工程师:
我使用MSP432P4011处理器
我的项目 有6个模拟量
前2个模拟量需要差分输入 后4个模拟量普通单端输入
A0-A1 差分输入1
A2-A3 差分输入2
A4 普通单端输入1
A5 普通单端输入2
A6 普通单端输入3
A7 普通单端输入4
这样混合用可以的是吧
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.
请问TI工程师:
我使用MSP432P4011处理器
我的项目 有6个模拟量
前2个模拟量需要差分输入 后4个模拟量普通单端输入
A0-A1 差分输入1
A2-A3 差分输入2
A4 普通单端输入1
A5 普通单端输入2
A6 普通单端输入3
A7 普通单端输入4
这样混合用可以的是吧
看着没啥问题,附上差分的例程
/* --COPYRIGHT--,BSD
* Copyright (c) 2017, 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 - Differential Mode with 2's Compliment
*
* Description: This example will use the ADC14 module mode in differential
* mode and take advantage of the 2's compliment mode. One ADC memory location
* is set to sample the differential voltage between terminals A0 and A1. The
* sample timer is used to periodically sample the difference in the value,
* the value is converted is float, and the value is stored in memory for the
* user to observe in the debugger.
*
* MSP432P4111
* ------------------
* /|\| |
* | | |
* --|RST P5.5 |<----- A0 In
* | P5.4 |<----- A1 In
* | |
* | |
*
******************************************************************************/
/* DriverLib Includes */
#include <ti/devices/msp432p4xx/driverlib/driverlib.h>
/* Standard Includes */
#include <stdint.h>
#include <string.h>
/* Statics */
static volatile float adcResult;
static float convertToFloat(uint16_t result);
int main(void)
{
/* Halting WDT */
MAP_WDT_A_holdTimer();
MAP_Interrupt_enableSleepOnIsrExit();
/* Enabling the FPU with stacking enabled (for use within ISR) */
MAP_FPU_enableModule();
MAP_FPU_enableLazyStacking();
/* Initializing ADC (MCLK/1/1) */
MAP_ADC14_enableModule();
MAP_ADC14_initModule(ADC_CLOCKSOURCE_MCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_1,
0);
/* Configuring ADC Memory (ADC_MEM0 A0/A1 Differential) in repeat mode */
MAP_ADC14_configureSingleSampleMode(ADC_MEM0, true);
MAP_ADC14_configureConversionMemory(ADC_MEM0, ADC_VREFPOS_AVCC_VREFNEG_VSS,
ADC_INPUT_A0, true);
/* Setting up GPIO pins as analog inputs */
MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5,
GPIO_PIN5 | GPIO_PIN4, GPIO_TERTIARY_MODULE_FUNCTION);
/* Switching data mode to 2's Complement mode */
MAP_ADC14_setResultFormat(ADC_SIGNED_BINARY);
/* Enabling sample timer in auto iteration mode and interrupts*/
MAP_ADC14_enableSampleTimer(ADC_AUTOMATIC_ITERATION);
MAP_ADC14_enableInterrupt(ADC_INT0);
/* Enabling Interrupts */
MAP_Interrupt_enableInterrupt(INT_ADC14);
MAP_Interrupt_enableMaster();
/* Triggering the start of the sample */
MAP_ADC14_enableConversion();
MAP_ADC14_toggleConversionTrigger();
/* Going to sleep */
while (1)
{
MAP_PCM_gotoLPM0();
}
}
/* This interrupt happens every time a conversion has completed. Since the FPU
* is enabled in stacking mode, we are able to use the FPU safely to perform
* efficient floating point arithmetic.*/
void ADC14_IRQHandler(void)
{
uint64_t status;
status = MAP_ADC14_getEnabledInterruptStatus();
MAP_ADC14_clearInterruptFlag(status);
if(status & ADC_INT0)
{
adcResult = convertToFloat(MAP_ADC14_getResult(ADC_MEM0));
}
}
//![Conversion to Real Value]
/* Converts the ADC result (14-bit) to a float with respect to a 3.3v reference
*/
static float convertToFloat(uint16_t result)
{
int32_t temp;
if(0x8000 & result)
{
temp = (result >> 2) | 0xFFFFC000;
return ((temp * 3.3f) / 8191);
}
else
return ((result >> 2)*3.3f) / 8191;
}
//![Conversion to Real Value]