打印
[MCU]

ADS1115 读低八位直接显示255

[复制链接]
360|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
flycamelaaa|  楼主 | 2020-12-7 11:11 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
调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;
}

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

610

主题

2250

帖子

0

粉丝