bq24735 I2C communication

fordmiki
Posts: 2
Joined: Fri Dec 02, 2022 4:27 pm

bq24735 I2C communication

Postby fordmiki » Fri Dec 02, 2022 4:51 pm

Dear all,

I am trying to setup the bq24735 power management unit with ESP32-WROOM-32.

I have a problem with writing information to the BQ_CHARGE_OPTION_REG. Here is a recording from the logical analyzer:
esp32.png
esp32.png (18.89 KiB) Viewed 729 times
The NACK is the problem. According to the datasheet write sequence should be this:
datapacket.png
datapacket.png (22.12 KiB) Viewed 729 times
Here is the code. The i2c_init(); happened successfully.
  1. #define     BQ_SLAVE_ADDR               0x12 >> 1
  2. #define     BQ_CHARGE_OPTION_REG                0X12 >> 1
  3. #define     I2C_MASTER_PORT                         I2C_NUM_0
  4. #define     I2C_MASTER_TIMEOUT_MS           300
  5.  
  6.  
  7. void app_main(void) {
  8.  
  9.     ESP_ERROR_CHECK(i2c_init());  //init is OK
  10.  
  11.     uint8_t chargeOption[3] = {BQ_CHARGE_OPTION_REG, 0xf9, 0x82};
  12.  
  13.     ESP_ERROR_CHECK(
  14.             i2c_master_write_to_device(I2C_MASTER_PORT, BQ_SLAVE_ADDR, chargeOption, 3, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS));
  15. }
bq24735 datasheet:
https://www.ti.com/lit/ds/symlink/bq247 ... e.com%252F

Does anyone have a soolution to this? Or are there any bq libraries already implemented?

fordmiki
Posts: 2
Joined: Fri Dec 02, 2022 4:27 pm

Re: bq24735 I2C communication

Postby fordmiki » Tue Dec 06, 2022 3:41 pm

The problem is in i2c addressing. In this case the slave address has 7 bits and it is needed to be shifted so the write bit is 0. Command registers need not be shifted, but he slave address has to.

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot], zelenecul and 130 guests