|
msp430g2553的有单通道程序,多通道怎么改
[复制链接]
5芯积分
求大神帮忙啊。。。。。
#include
#include "lcd12864.h"
float temp;
float voltage;
void main(void)
{
unsigned char s2[] ={"MSP430GLAUNCHPAD"};
WDTCTL = WDTPW+WDTHOLD; // 停止看门狗定时器
P2SEL=0x00;//p2.6和p2.7管教默认的第一功能是外部晶体振荡器的接口,设置第二功能-通用IO口
P2DIR |= BIT6+BIT7;//设置P2.6,P2.7位输出
/*将内部DCO校准至1MHz*/
BCSCTL1 |= CALBC1_1MHZ;
DCOCTL |= CALDCO_1MHZ;
BCSCTL2 |= SELM_0;//MCLK采用1M的内部DCO
BCSCTL2 |= DIVS_2;//SMCLK采用250K的时钟
Ini_Lcd();
Disp_HZ(8, s2);
ADC10AE0 |= BIT0;
ADC10AE0|=0X1a;
ADC10CTL0 |= SREF_1+REF2_5V+REFON+ADC10IE;//将AD10基准设置为2.5V 开启AD允许中断
ADC10CTL0 |= ADC10SHT_0+MSC;//打开AD转换,过采样率设置为4个采样周期
ADC10CTL1 |= ADC10SSEL_3+SHS_0;//选择250K的采样时钟,用ADC10SC触发采集
ADC10CTL1 |= CONSEQ_2+INCH_0;//采样模式,通道0
ADC10CTL0 |= ADC10ON;
ADC10AE0 |= 0xFF;
ADC10CTL0 |= ADC10SC+ENC;
_EINT();//允许中断
while(1)
{
float max[32];
//float ma=0.;
float dave=0;
unsigned int i,j;
//delay_ms(50);
ADC10CTL0 |= ENC+ADC10SC;
for(j=0;j<10;j++)
{
temp = ADC10MEM;
max[j] = temp*25/10230;
dave += max[j]/10;
}
Disp_SZ1(16, (int)dave+'0');
Disp_SZ1(17, '.');
Disp_SZ1(18, (int)(dave*10)%10+'0');
Disp_SZ1(19, (int)(dave*100)%10+'0');
}
}
//AD中断服务程序
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR (void)
{
__bic_SR_register_on_exit(LPM0_bits);//将SR里的CPUOFF位置0
}
//定时器输出单元
#pragma vector=TIMER0_A0_VECTOR
__interrupt void ta0_isr(void)
{
TACTL = 0;
__bic_SR_register_on_exit(LPM0_bits);//将SR里的CPUOFF位置0
}
|
|