调ADS1115,低八位读出来的值总是显示255,所以最小只能调到255,
希望大侠们速度帮下忙!
void main()
{
ulong temp1=0,temp2=0,temp3=0;
int i;
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
P1DIR|=BIT0;
P3DIR=0XFF;
BCSCTL1&=~XT2OFF; //设置XT2为有效
do
{
IFG1&=~OFIFG; //消除振荡器失效标志
for(i=0xff;i>0;i--); //稳定时间
}
while((IFG1&OFIFG)!=0); //如果振荡器失效标志存在,则继续循环
BCSCTL2|=SELM1; //设置MCLK=XT2
LCD_Configuration();
//Confige1115(0);
while(1)
{
Confige1115(0);
temp1=read1115();
Confige1115(1);
temp2=read1115();
LCD_psd(1,1,temp1);
LCD_psd(2,1,temp2);
//LCD_psd(3,1,temp3);
}
}
uint read1115()
{
ulong result_l,result_h;
ulong result;
start();
write1byte(address);
ack();
//delay_ms(2);
write1byte(conversion);
ack();
stop();
delay_us(2);
start();
write1byte(address+1);
ack();
delay_us(5);
result_h=read1byte();
ack();
delay_us(2);
result_l=read1byte();
ack();
stop();
result_h <<= 8;
result=result_h | result_l;
return result_l;
} |