|
- void lcdxianshi();
- void AD();
- void clock_init()
- {
-
- P1DIR |= BIT7; // MCLK set out to pins
- P1SEL |= BIT7;
- __bic_SR_register(SCG0); // Enable the FLL control loop
- }
- void main()
- {
- WDTCTL=WDTPW+WDTHOLD;
- AD();
- //unsigned char i;
- clock_init(); //时钟初始化
- int_port(); //lcd端口初始化
- lcdinit(); //LCD初始化
- _EINT();
- lcdxianshi();
- }
- void lcdxianshi()
- {
- diplay_1();
- diplay_2();
- diplay_3();
- diplay_4();
- while(1)
- {
- for(int i=0;i<20;i++)
- {
- ADC10CTL0 |=ENC+ADC10SC; //开始转换
- while((ADC10CTL0 &ADC10IFG)==0); //等待 ADC10IFG 标志变高(转换完成)
- ADC10_Result=ADC10_Result+ADC10MEM; //读取采样结
- }
- ADC10_Result= ADC10_Result/20;
-
- xianshi =(24*ADC10_Result);
- a[0]=(unsigned char)(xianshi/10000);
- a[0]=a[0]+0x30;
- a[1]='.';
- a[2]=(unsigned char)((xianshi%10000)/1000);
- a[2]=a[2]+0x30;
- a[3]=(unsigned char)((xianshi%1000)/100);
- a[3]=a[3]+0x30;
- a[4]=(unsigned char)((xianshi%100)/10);
- a[4]=a[4]+0x30;
- diplay_5();
- delay(5000);
- }
- }
- void AD()
- {
- ADC10CTL1 |= CONSEQ_2; //单通道重复采样模式
- ADC10CTL0 |= SREF_1+REFON+REF2_5V;//选择内部参考源 2.5V,打开基准源
- ADC10CTL0 |= ADC10SHT_3+MSC; //ADC10SHT_x为采样保持时间设置位(64个ADC10CLK周期)多重采样和//转换。这一位只用于序列或重复采样模式。0 SHI 信号的上升沿触发每个采样和转换。
- ADC10CTL1|= ADC10SSEL_1+ADC10DIV_1+SHS_0; //ACLK2 分 频 为 采 样 时 钟 ,用ADC10SC 触发采集
- ADC10CTL1 |=INCH_4; //选择通道 A1
- ADC10CTL0 |= ADC10ON; //开启 ADC10
- ADC10AE0 |= BIT4; //开启外部通道 A1
- BCSCTL1 = CALBC1_1MHZ; // Set DCO 为16MHz
- DCOCTL = CALDCO_1MHZ;
-
- }
复制代码
|
|