对参考电压的选择有很多疑问,比如下面这个例子我在很多地方都看到过 void main(void)
{
WDTCTL = WDTPW+WDTHOLD;
ADC12CTL0 = ADC12ON+SHT0_8+MSC;
ADC12CTL1 = SHP+CONSEQ_2;
ADC12IE = 0x01;
ADC12CTL0 |= ENC;
ADC12CTL0 |= ADC12SC;
}
在上面的这段代码里,我不知道他到底是怎么设置参考电压的
在ADC12CTL0寄存器中, 有一个REF2_5V,和REFON,说是选择内部参考电压的就是2.5V和1.5V
但是在ADC2MCTLx寄存器中SREF 又有6中情况,应该是选择外部参考电压的把,
那在上面这个程序中,如何知道VR+和VR-呢,怎么计算测量的电压
还有就是我想用内部参考电压,测量430内部的温度传感器的温度,一下的初始化设置对不对啊
ADC12CTL0=ADC12ON+SHT0_15+MSC+REF2_5V;
ADC12CTL1=SHP+CONSEQ_2;
ADC12MCTL0=INCH_10;
ADC12IE=0x01;
ADC12CTL0|=ENC;
ADC12CTL0|=ADC12SC;
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
reference is 1.5 V when REF2_5V = 0.
REFON=1时,如果REF2_5V=0,那么内部参考电压为1.5V,REF2_5V=1时内部参考电压为2.5V
选择外部参考电压通过SREFx,从datasheet里可以看到有很多种选择,Vref这种是内部参考电压,Veref这种是外部参考电压。
可以参考一下
//******************************************************************************
// MSP430G2x33/G2x53 Demo - ADC10, Sample A10 Temp and Convert to oC and oF
//
// Description: A single sample is made on A10 with reference to internal
// 1.5V Vref. Software sets ADC10SC to start sample and conversion - ADC10SC
// automatically cleared at EOC. ADC10 internal oscillator/4 times sample
// (64x) and conversion. In Mainloop MSP430 waits in LPM0 to save power until
// ADC10 conversion complete, ADC10_ISR will force exit from any LPMx in
// Mainloop on reti. Temperaure in oC stored in IntDegC, oF in IntDegF.
// Uncalibrated temperature measured from device to device will vary with
// slope and offset - please see datasheet.
// ACLK = n/a, MCLK = SMCLK = default DCO ~1.2MHz, ADC10CLK = ADC10OSC/4
//
// MSP430G2x33/G2x53
// -----------------
// /|| XIN|-
// | | |
// --|RST XOUT|-
// | |
// |A10 |
//
// D. Dang
// Texas Instruments Inc.
// December 2010
// Built with CCS Version 4.2.0 and IAR Embedded Workbench Version: 5.10
//******************************************************************************
#include "msp430g2553.h"
long temp;
long IntDegF;
long IntDegC;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
ADC10CTL1 = INCH_10 + ADC10DIV_3; // Temp Sensor ADC10CLK/4
ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE;
__enable_interrupt(); // Enable interrupts.
TACCR0 = 30; // Delay to allow Ref to settle
TACCTL0 |= CCIE; // Compare-mode interrupt.
TACTL = TASSEL_2 | MC_1; // TACLK = SMCLK, Up mode.
LPM0; // Wait for delay.
TACCTL0 &= ~CCIE; // Disable timer Interrupt
__disable_interrupt();
while(1)
{
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
__bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled
// oF = ((A10/1024)*1500mV)-923mV)*1/1.97mV = A10*761/1024 - 468
temp = ADC10MEM;
IntDegF = ((temp - 630) * 761) / 1024;
// oC = ((A10/1024)*1500mV)-986mV)*1/3.55mV = A10*423/1024 - 278
temp = ADC10MEM;
IntDegC = ((temp - 673) * 423) / 1024;
__no_operation(); // SET BREAKPOINT HERE
}
}
// ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR (void)
{
__bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR)
}
#pragma vector=TIMER0_A0_VECTOR
__interrupt void ta0_isr(void)
{
TACTL = 0;
LPM0_EXIT; // Exit LPM0 on return
}
一周热门 更多>