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.

BQ25121 i2c example code for changing sys output

Other Parts Discussed in Thread: BQ25121, BQ25120

I have trouble getting BQ25121 to put out desired voltage output, kindly share microcontrolller code in C or Arduino code to illustrate how it should be done .

  • Changing the SYS output is done by changing the value in register 0x06h.  See section 9.6.7 in the bq25120 datasheet for a table of the available output voltages.  The output voltage can be changed once the device is powered, and can be done while the output is acitve.  If you are looking to change the LS/LDO output, to change the output voltage the LS/LDO output must be disabled first, the output voltage changed, and then the output re-enabled.

  • Steve,i did exactly as you said. as soon as the 2.5v is given the micro is run using introsc and 0x06 is written with 0xFF whixh means it should give 3.3v but it's not doing so, also I have a custom board and tried this on several 2 or 3 different PCBs, idk if Soldering is a problem.

  • Are you able to try this with the EVM and your code? 

  • I have directly implemented this IC in my design ,I I'll share the code I'm using and the schematic  I have on my board shortly.

    thank you for supporting!

  • following Attached is the schematic of BQ25120/21 which I have on my custom board, please tell me if I should have any additional impovements in circuit? my requirements are just max 100mA (that too a max pulse from vibration motor) @ max 3.3vDC and Lowest power consumption!

    The following is the very simple Arduino code that I used to write to the BQ25121's/20's 0x06 sys output register:

      Wire.beginTransmission(0xD4); // also tried using 7-bit addresss 0x6A
      Wire.write(0x06);
      Wire.write(0xFF);// for outputting 3.3vDC
      Wire.endTransmission();

  • Are you able to change any other parameter over I2C, or is it just changing the output voltage that is not working?

    An easy one to observe is the charging current.  If you aren't able to perform any reads or writes, check the following:

    * If operating with battery only, is the /CD pin pulled high?

    * Verify your pull-ups on the SDA and SCL pins, and verify the commands are sent.  The schematic does not show the pull-up values.

  • Steve, I tried reading also but it always returned 0xFF on whatever registers I read!
    1) No, I do not have CD pin high, its pulled low by its inbuilt 900k resistor and thats it ,I didnt even break out CD pin as you can see in schematics also because I would have to perform VIA in PAD as couldn't have done the fan outs anyway given the very low clearance it calls for!

    2) I have pullups on SDA and SCL, they are 10k both and I also have 3 other sensors on the I2c bus sharing the same bus but they are working fine BUT sometimes they give problems!! like the software says it found a certain sensor on the i2c bus and also starts reading it but gives 00 values instead of meaningful reasults ,Im speculating now that this might be BQ25121s problem related!

    EDIT:

    Is every-other thing in the schematic fine? 

  • A few comments:

    * You will want to control the /CD pin with a GPIO from your MCU. This allows enabling and disabling charge when VIN is connected, and when operating on battery only, turning on/off the I2C interface to conserve power when not talking to the part.
    * The PMID cap needs to have at least 3uF of ceramic capacitance on the pin, as it is the input to the buck. Be sure to look at the voltage rating of the cap, as well as the DC Bias de-rating curve in the cap datasheet. Right now it only shows 1uF, and that may be much less depending on the de-rated value.
    * The TS pin must either be pulled above 60% of VIN to disable the TS function, or you need to disable the TS function in the registers if you want to charge a battery. You can not leave it floating.

    To de-bug the I2C issue, I suggest removing the bq25120 from your system and seeing if it resolves the communication with the other devices.
  • Steve Schnier said:
    A few comments:

    * You will want to control the /CD pin with a GPIO from your MCU. This allows enabling and disabling charge when VIN is connected, and when operating on battery only, turning on/off the I2C interface to conserve power when not talking to the part.

    Does this means that the i2c is actually disabled ? because that I do not have the CD pulled high?

    Steve Schnier said:
    A few comments:
    * The TS pin must either be pulled above 60% of VIN to disable the TS function, or you need to disable the TS function in the registers if you want to charge a battery. You can not leave it floating.

    Is it that needed, I mean to the extent that If I do not have it connected which is the case right now! that it will not function!?

  • If you are operating with battery only, then I2C is disabled when you have /CD pulled low (there is an internal pull-down, so if left unconnected, it is pulled low).
    Regarding the TS pin, the device will function, but will not charge as it will take the floating input as an incorrect TS pin voltage and disable charging.
  • Steve Schnier said:
    If you are operating with battery only, then I2C is disabled when you have /CD pulled low (there is an internal pull-down, so if left unconnected, it is pulled low).

    Is there a way to access the BQ PMIC without controlling CD line for now?  as I do not have /CD broken down or connected to any MCU pin!

  • When you have a valid VIN supply, the I2C interface is active and you can communicate with the device whether /CD is pulled high or low.  You can configure the device in this way, and when you remove the VIN source the part will disable the I2C interface. This should be okay for most conditions, but you will miss out on servicing any interrupts on INT due to the inability to talk to the part on battery only if you can't pull /CD high to re-enable the I2C interface.

  •  

    Quote:

    The TS pin must either be pulled above 60% of VIN to disable the TS function, or you need to disable the TS function in the registers if you want to charge a battery. You can not leave it floating.

    What if I keep the TS pin floating BUT as soon as the system is started then just disable the TS function so that battery can charge, then will the normal battery charging happen? and also is there any current leakage etc if I have TS pin floating?

    also,

    Is it ok if I mount the PMID cap on the top layer while all other PMIC supportive components including PMIC are on the bottom layer?

  • If you leave the TS pin floating, the part will not charge until you have the "Enable TS Pin" bit set to 0.  You will then be relying on the boot sequence when you plug in VIN to ensure that charging starts with a dead battery (battery below BUVLO).  No other concerns for that.

    The PMID cap is the input cap for the switcher.  If the cap is connected through low impedance via's then there should not be an issue.

  • any heads up steve?
  • Steve Schnier said:

    Are you able to try this with the EVM and your code? 

    I bought the EVM tested with it, still not able to programme and change the sys output, the i2c on my AVR hangs at that point where it tries to write to the register 0x06 with value 0xFF to put out 3.3v.

  • Nishant,

    could you paste your code snippet here? also do you have an I2C logic analyzer? Are your pull-up resistors tied to VSYS?

    regards,

    Gautham