This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

BQ25713 IIC通信失败,不回复ACK

Other Parts Discussed in Thread: BQ25713, EV2400, BQSTUDIO

尝试使用52832单片机的模拟I2C与BQ25713通信,结果发现MCU给BQ25713发出START和ADDRESS(D7)之后,无法接收到BQ25713回复的ACK。下图是START开始的波形:

上方波形图的黄色为SDA、蓝色为SCL,在52832发送START及0xD7之后,SDA线无法收到BQ25713的ACK低电平。

采用单节电池设计,未配置情况下,VSYS电压为2.85V;

原理图如下:

请帮分析原因,谢谢。

代码如下:

#define Dev_Addr 0xD4
#define DevID_Addr 0X2F
#define PIN_IIC_SDA     34
#define PIN_IIC_SCL     32


#define SDA_H            nrf_gpio_pin_write(PIN_IIC_SDA,1)       
#define SDA_L            nrf_gpio_pin_write(PIN_IIC_SDA,0)       

#define SCL_H            nrf_gpio_pin_write(PIN_IIC_SCL,1)      
#define SCL_L            nrf_gpio_pin_write(PIN_IIC_SCL,0)

#define SDA_read        nrf_gpio_pin_read(PIN_IIC_SDA)

#define IIC_DELAY    10

//初始IIC
void BQ_25713_IIC_Init(void)
{                
    nrf_gpio_cfg_output(PIN_IIC_SDA);
    nrf_gpio_cfg_output(PIN_IIC_SCL);
    SCL_H;
    SDA_H;
    nrf_delay_us(IIC_DELAY);
}
//产生启始信号
void BQ_25713_IIC_Start(void)
{
    SDA_OUT_BQ();     //sdaÏßÊä³ö
    SDA_H;
    SCL_H;
    nrf_delay_us(IIC_DELAY);
     SDA_L;//START:when CLK is high,DATA change form high to low
    nrf_delay_us(IIC_DELAY);
    SCL_L ;//ǯסI2C×ÜÏߣ¬×¼±¸·¢ËÍ»ò½ÓÊÕÊý¾Ý
}      
//产生停止信号
void BQ_25713_IIC_Stop(void)
{
    SDA_OUT_BQ();//sdaÏßÊä³ö
    SCL_L;
    SDA_L;//STOP:when CLK is high DATA change form low to high
     nrf_delay_us(IIC_DELAY);
    SCL_H;
    SDA_H; //·¢ËÍI2C×ÜÏß½áÊøÐźÅ
    nrf_delay_us(IIC_DELAY);
    nrf_delay_us(10);
}
//等待应答
//·µ»ØÖµ£º1£¬½ÓÊÕÓ¦´ðʧ°Ü
//        0£¬½ÓÊÕÓ¦´ð³É¹¦
uint8_t BQ_25713_IIC_Wait_Ack(void)
{
    uint8_t ucErrTime=0;
    SDA_IN_BQ();      //SDAÉèÖÃΪÊäÈë  
    SDA_H;
    nrf_delay_us(1);       
    SCL_H;
    nrf_delay_us(IIC_DELAY);    
    while(SDA_read)
    {
        ucErrTime++;
        if(ucErrTime>250)
        {
            BQ_25713_IIC_Stop();
            return 1;
        }
    }
    SCL_L ;//ʱÖÓÊä³ö0     
    nrf_delay_us(IIC_DELAY);    
    return 0;  
}
//²úÉúACKÓ¦´ð
void BQ_25713_IIC_Ack(void)
{
    SCL_L ;
    SDA_OUT_BQ();
    SDA_L;
    nrf_delay_us(IIC_DELAY);
    SCL_H;
    nrf_delay_us(IIC_DELAY);
    SCL_L ;
}
//²»²úÉúACKÓ¦´ð            
void BQ_25713_IIC_NAck(void)
{
    SCL_L ;
    SDA_OUT_BQ();
    SDA_H;
    nrf_delay_us(IIC_DELAY);
    SCL_H;
    nrf_delay_us(IIC_DELAY);
    SCL_L ;
}                                          
//IIC·¢ËÍÒ»¸ö×Ö½Ú
//·µ»Ø´Ó»úÓÐÎÞÓ¦´ð
//1£¬ÓÐÓ¦´ð
//0£¬ÎÞÓ¦´ð              
void BQ_25713_IIC_Send_Byte(uint8_t txd)
{                        
    int i;  
    SDA_OUT_BQ();       
    SCL_L;
    nrf_delay_us(IIC_DELAY);
     for(i=0;i<8;i++)
    {
    if(txd&0x80)
        SDA_H;
    else
        SDA_L;
    txd<<=1;
    
    nrf_delay_us(IIC_DELAY/2);
    SCL_H;
    nrf_delay_us(IIC_DELAY);
    SCL_L;
    nrf_delay_us(IIC_DELAY/2);
    }
}

//¶Á1¸ö×Ö½Ú£¬ack=1ʱ£¬·¢ËÍACK£¬ack=0£¬·¢ËÍnACK   
 uint8_t BQ_25713_IIC_Read_Byte(unsigned char ack)
{
    unsigned char i,receive=0;
    SDA_IN_BQ();//SDAÉèÖÃΪÊäÈë
    nrf_delay_us(IIC_DELAY);
  for(i=0;i<8;i++ )
    {
        SCL_L ;    
        nrf_delay_us(IIC_DELAY);
        SCL_H;
        receive<<=1;
    if(SDA_read)receive++;   
        nrf_delay_us(IIC_DELAY);
  }                    
  if (ack==0)
        BQ_25713_IIC_NAck();//·¢ËÍnACK
  else
        BQ_25713_IIC_Ack(); //·¢ËÍACK   
  return receive;
}

void SDA_OUT_BQ(void)
{
    nrf_gpio_cfg_output(PIN_IIC_SDA);
}


void SDA_IN_BQ(void)
{
    nrf_gpio_cfg_input(PIN_IIC_SDA,NRF_GPIO_PIN_NOPULL);  
}    


uint8_t BQ25713_ReadOneByte(uint16_t ReadAddr)
{                  
    uint8_t temp=0;                                                                                  
    BQ_25713_IIC_Start();  
    
    BQ_25713_IIC_Send_Byte(Dev_Addr);       //·¢ËÍдÃüÁî
    BQ_25713_IIC_Wait_Ack();
    
    BQ_25713_IIC_Send_Byte(ReadAddr);   //·¢Ë͵͵ØÖ·
    BQ_25713_IIC_Wait_Ack();
    
    BQ_25713_IIC_Start();              
    BQ_25713_IIC_Send_Byte(Dev_Addr+1);           //½øÈë½ÓÊÕģʽ               
    BQ_25713_IIC_Wait_Ack();
    
   temp=BQ_25713_IIC_Read_Byte(0);
    
   BQ_25713_IIC_Stop();//²úÉúÒ»¸öÍ£Ö¹Ìõ¼þ        
    return temp;
}

uint8_t BQ25713_Init(void)
{
    
    uint8_t whoami;
    
    /*¶ÁÈ¡WHO_AM_IÅжÏLIS3DHÊÇ·ñ´æÔÚ */
    whoami=BQ25713_ReadOneByte(DevID_Addr);

    USER_RTT("WHOMI= 0x%02x\r\n",(uint8_t)whoami);

    if(whoami != 0x88)
    {
        USER_RTT("BQ25713 is not found!\r\n");
    }
    else
    {
        USER_RTT("BQ25713 is init ok ...\r\n");
    }

}

  • 您好,使用EV2400是否能正常通讯。
  • 没有使用EV2400,以下是我们原理图

  • 您好,建议用BQSTUDIO连接一下,确认是芯片问题还是别的问题。
  • 问题已解决,是地址问题,谢谢!
  • 您好,很高兴您的问题已经解决,感谢分享经验。
  • 现在有另外一个问题,我设置相关参数后,发现无法充电。
    一下是我的配置参数:
    uint8_t BQ25713_Init(void)
    {

    uint8_t whoami;

    whoami=BQ25713_ReadOneByte(DevID_Addr);

    USER_RTT("WHOMI= 0x%02x\r\n",(uint8_t)whoami);

    if(whoami != 0x88)
    {
    USER_RTT("BQ25713 is not found!\r\n");
    }
    else
    {
    USER_RTT("BQ25713 is init ok ...\r\n");
    }
    if(Write_Reg_Len(0x34,0x9034)) return 1;

    if(Write_Reg_Len(0x34,0x8034)) return 1;

    if(Write_Reg_Len(0x00,0x0F0A)) return 1;//Config Charge Option 0

    if(Write_Reg_Len(0x02,0x0200)) return 1;//Config Charge Current

    if(Write_Reg_Len(0x04,0x1070)) return 1;//Config Charge Voltage

    if(Write_Reg_Len(0x06,0x099C)) return 1;//Config OTG Voltage

    if(Write_Reg_Len(0x08,0x5000)) return 1;//Config OTG Current

    if(Write_Reg_Len(0x0A,0x0100)) return 1;//Config Input Voltage

    if(Write_Reg_Len(0x0C,0x1800)) return 1;//Config Minimum System Voltage

    if(Write_Reg_Len(0x0E,0x4100)) return 1;//Config Input Current

    if(Write_Reg_Len(0x30,0xE210)) return 1;//Config Charge Option 1

    if(Write_Reg_Len(0x32,0x32BF)) return 1;//Config Charge Option 2

    if(Write_Reg_Len(0x34,0x0834)) return 1;//Config Charge Option 3

    if(Write_Reg_Len(0x36,0x4A65)) return 1;//Config Prochot Option 0

    if(Write_Reg_Len(0x38,0x81FF)) return 1;//Config Prochot Option 1

    if(Write_Reg_Len(0x3A,0xA0FF)) return 1;//Config ADC Option

    return 0;
    }

    调试日志如下:

    电池放完电后:
    00> Charge_Status = [0x8010]
    00> Prochot_Status = [0xA844]
    00> Read_Battery = [2880]
    00> Input_Current = [0]
    00> Charge_Current = [0]
    00> DisCharge_Current = [0]
    00> Vbus_Voltage = [4736]

    没有充电电流???VSYS电压0.75V???

    电池有3.7V情况下:

    00> Charge_Status = [0x8050]
    00> Prochot_Status = [0xA84C]
    00> Read_Battery = [3840]
    00> Input_Current = [0]
    00> Charge_Current = [10432]
    00> DisCharge_Current = [51456]
    00> Vbus_Voltage = [4736]

    充电电流10mA???VSYS电压2.96V

    输入电流读取的是0x2B寄存器,始终未0???

    还请帮忙分析一下原因,谢谢!

  • 您好,请确认用默认参数是否能充电。

    如果不能充电请参考下面文档确认电路是否有问题。

    8228.BQ2571X_SchematicChecklist_CalculationTool.pdf

  • 默认参数无法充电,我们电源部分电路图如下:

    请帮忙看一下,谢谢!