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.

bq25892 i2c 通讯不能收到应答信号

void Drv_I2C_Config( void )

{

        GPIO_InitTypeDef GPIO_InitStruct;

 

/* GPIO Ports Clock Enable */

I2C1_SCL_GPIO_CLK_ENABLE();

        I2C1_SDA_GPIO_CLK_ENABLE();

 

/*Configure GPIO pin : BAT_INT_Pin */

GPIO_InitStruct.Pin = BAT_I2C1_SCL_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;

HAL_GPIO_Init(BAT_I2C1_SCL_GPIO_Port, &GPIO_InitStruct);

 

GPIO_InitStruct.Pin = BAT_I2C1_SDA_Pin;

HAL_GPIO_Init(BAT_I2C1_SDA_GPIO_Port, &GPIO_InitStruct);

       

        I2C_SCL_H;    

        I2C_SDA_H;

}

 

void Drv_I2C_Start( void )

{

        I2C_SCL_H;

       

        I2C_SDA_H;

        i2c_Delay();

              

        I2C_SDA_L;

        i2c_Delay();

       

        I2C_SCL_L;

        i2c_Delay();  

}

 

/***************************************************************

Name: Drv_I2C_Stop

Params: void

Return: void

Description: CPU·¢ÆðI2C×ÜÏßÍ£Ö¹ÐźÅ

***************************************************************/

void Drv_I2C_Stop( void )

{

        I2C_SDA_L;

       

        I2C_SCL_H;

        i2c_Delay();

       

        I2C_SDA_H;

       

}

 

void Drv_I2C_SendByte( uint8_t dat )

{

        uint8_t i;

        for (i = 0; i < 8; i++)

        {

               I2C_SCL_L;

               i2c_Delay();

              

               if(dat & 0x80)

               {

                       I2C_SDA_H;

               }

               else

               {

                       I2C_SDA_L;

               }

               dat <<= 1;    

               i2c_Delay();

              

               I2C_SCL_H;

               i2c_Delay();

        }

        I2C_SCL_L;

        i2c_Delay();

}

 

uint8_t Drv_I2C_WaitAck(void)

{

        uint8_t re;

        SDA_Input();

        I2C_SCL_L;

        i2c_Delay();

       

        I2C_SDA_H;    

        i2c_Delay();

       

        I2C_SCL_H;    

        i2c_Delay();

       

        if(I2C_SDA_GET)

        {

               re = 1;

        }

        else

        {

               re = 0;

        }

        I2C_SCL_L;

        i2c_Delay();

       

        SDA_Output();

        return re;

}

 

我使用的是stm32l8的芯片,i2c周期大概是10us,写地址0x6B,无应答信号,我使用这个程序写eeprom的地址0xA0,是有应答。

原理图如下,VCC_USB使用5V电压输入,VBAT和VBAT_SYS_OUT都有有4.2V电压。