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.

[参考译文] BQ76972:I2C 扫描器件地址读取

Guru**** 2387830 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/power-management-group/power-management/f/power-management-forum/1531336/bq76972-i2c-scan-device-address-read

器件型号:BQ76972

工具/软件:

TI 团队大家好、

我已附加 I2C 扫描器件代码、该代码用于扫描连接在 I2C 通道上的器件。 但如果我在同一通道上写入数据、则不起作用

谢谢您、  

// To find the device address //
void I2C_ScanBus()
{
    char msg[64];
    uint8_t devicesFound = 0;

    for (uint8_t address = 1; address < 127; address++)
    {
    	HAL_GPIO_WritePin(MCU_BMS_RESET_GPIO_Port, MCU_BMS_RESET_Pin, GPIO_PIN_SET);
    	HAL_Delay(100);
    	HAL_GPIO_WritePin(MCU_BMS_RESET_GPIO_Port, MCU_BMS_RESET_Pin, GPIO_PIN_RESET);
    	HAL_Delay(100);
        if (HAL_I2C_IsDeviceReady(&hi2c3, address << 1, 3, 10) == HAL_OK)
        {
            snprintf(msg, sizeof(msg), "Found I2C device at 0x%02X\r\n", address << 1);
            RS485_Transmit((uint8_t*)msg, strlen(msg));
            devicesFound++;
        }
    }

    if (devicesFound == 0)
    {
        RS485_Transmit((uint8_t*)"No I2C devices found\r\n", 23);
    }
}

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!  

     有关寄存器以及如何与器件通信的说明、请参阅技术参考手册 (www.ti.com/.../sluuby2b.pdf)。 我们可以回答有关器件的具体问题、但我们希望我们的客户能够查看/调试其代码。 如果您在使用微控制器时遇到问题、请联系 MCU 团队。 如果您对 TRM 有任何具体问题、请发布另一个同样的主题。 谢谢你。  

    此致、  

    Arelis G. Guerrero