ADS1115's error

Posted on
  • Could anybody help me ?It's a ADS1115 .Please look at the following states:
    include       
    #include    
    #pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
    #define SDA PORTA_BIT6
    #define SCL PORTA_BIT7
    #define uint8_t unsigned char

    /*************************************/
    /串口初始化及发送/
    /
    *************************************/  ­
    void Sci0open(void)
    {
    SCI0BD=54;     //9600波特率设置
    SCI0CR1=0x00;  //正常8位模式,无奇偶校验位
    SCI0CR2=0X2C;  //接收中断允许
    }

    void Sci_send(char k)   //发一个字符
    {
    SCI0SR1_TDRE=1; 
    SCI0DRL=k;
    }
    void Sci_send_String(char *p)    //发字符串
    {
      while(*p) 
      {
        Sci_send(*p);
        p++;
        delay(2);
      }
    }

    /***************************************­****************************
                          起动总线函数               
    函数原型: void   Start_I2c();  
    功能:      启动I2C总线,即发送I2C起始条件.  
    ****************************************­**************************/
    void I2C_START() 

       SDA=1;            /发送起始条件的数据信号/
       Delay1us(20);
       SCL=1;
       Delay1us(20);      /起始条件建立时间大于4us,延时/
        
       SDA=0;            /发送起始信号/
       Delay1us(20);      /* 起始条件锁定时间大于4μs*/
            
       SCL=0;            /*钳住I2C总线,准备发送或接收数据 */
       Delay1us(20);
    }
    /
    ****************************************­*************************
                结束总线函数               
    函数原型: void   Stop_I2c();  
    功能:      结束I2C总线,即发送I2C结束条件.  

    /***************************************­*****************************

    通过I2C总线配置ADS1113
    注意:ADS115地址为1001000
    此处程序需要修改
    ****************************************­****************************/
    void Confige1113 (void)
    {
        unsigned char  i;
        table[0] = 0x90;     //CMD_Write,ADS115地址为1001000;
        table[1] = 0x01;     //指向配置寄存器
        table[2] = 0x90;     //设置配置寄存器的高八位0000 0000;连续转换模式
        table[3] = 0x00;     //设置配置寄存器的低八位1000 0000,即转换速率为128SPS
        I2C_START();         //发送起始信号
        for(i=0;i<4;i++)
        {   
          I2C_send(table[i]);//将table里面的数写入ads111­5
          check_ack();       //检查ADS1115的ACK信号
          if(I2C_ERROR==1)   //如果ADS115无ACK信号则退出
              break;
        }
        I2C_STOP();          //发送停止信号
    Why my finally result always output 00000. Is it any wrong about timing? I’m a new hand.Please help me!!
    NOTE: I have made a link in the above-mentioned ADS1115,if you need something about it,please click it.
    Your help will be appreciated!

  • Hi - I think you're posting on the wrong forum. What you have there is code written in C, and this forum is for Espruino (where code is written in JavaScript).

    What board are you using? You'd be better off asking at the manufacturer's forums.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

ADS1115's error

Posted by Avatar for user74439 @user74439

Actions