在做msp430g2553的ADC10外部参考电压时,想设置一个5V以上的外部参考电压,可怎么也弄不出来!请各位大虾指教指教!
下面是我的程序:
#include <intrinsics.h>
#include "1602-4.h"
#include "1602-4.c"
/********************************************
主函数
*******************************************/
void main()
{
WDTCTL = WDTPW + WDTHOLD; // 关闭看门狗
P1SEL|=BIT4;
P1DIR&=~BIT4;
ADC10CTL0 =SREF_2+ADC10SHT_2 + ADC10ON + ADC10IE; // ADC10ON, interrupt enabled
ADC10CTL1 = INCH_1; // input A1模拟信号输入选择通道A1即p1.1
ADC10AE0 |= 0x12; // PA.1 ADC option select使p1.1允许AD模拟输入信号
P1DIR |= 0x01; // Set P1.0 to output direction
ADC10CTL0 |= ENC + ADC10SC;
// LCD_init_first();
LCD_init();
TA0CCTL0 = CCIE; // CCR0 1ms中断
TA0CCR0 = 312;
TA0CTL = TASSEL_2 + MC_1; // SMCLK, upmode
//_BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
TA1CCTL0 = CCIE; // CCR0 1ms中断
TA1CCR0 = 312;
TA1CTL = TASSEL_2 + MC_1; // SMCLK, upmode
_BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
while(1)
{ if(j>100)
{
shuzhi=qushu*35/10;
lcd_diaoyong();
LCD_write_command(0x0c);
j=0;
}
}
}
/********************************************
*
定时器Timer0_A
*******************************************/
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer0_A (void)
{
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start开始转换
qushu=ADC10MEM;
j++;
__bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit
__bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR)
}
/********************************************
定时器Timer1_A
*******************************************/
#pragma vector=TIMER1_A0_VECTOR
__interrupt void Timer1_A (void)
{
P1OUT ^= 0x01;
__bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR)
}
/********************************************
*******************************************/
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void)
{
__bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR)
} |