SLUAAX5 August   2024 BQ25750 , BQ40Z80 , MSPM0L1306

 

  1.   1
  2.   Abstract
  3.   Trademarks
  4. 1Introduction
  5. 2The Role of MCU in Smart Battery System
  6. 3Application Example Using BQ25750, BQ40z80, and MSPM0L1306
    1. 3.1 Gauge Setup
    2. 3.2 Charger Setup
    3. 3.3 MCU Setup
    4. 3.4 Communication Protocol
    5. 3.5 MCU Code Example
    6. 3.6 Data Collected
  7. 4Summary
  8. 5References

MCU Code Example

The code for the MCU to poll the gauge for ChargingVoltage() is shown below.


 Code Example
                                        For Polling ChargingVoltage()

Figure 3-5 Code Example For Polling ChargingVoltage()

From TI’s SMBus Library, a predefined function is called to communicate with the gauge through SMBus. The target address is the device address, and the result of the request is stored in the voltage array. The same sequence is repeated for the ChargingCurrent() where the SMBus command is 0x14.


 SMBus function
                                        call for ChargingCurrent()

Figure 3-6 SMBus function call for ChargingCurrent()

The code to translate ChargingCurrent () is such to be compatible with the charger.


 Converting
                                        ChargingCurrent() Before Transmission To Charger

Figure 3-7 Converting ChargingCurrent() Before Transmission To Charger

From TI’s I2C Library, a predefined function is called to communicate with the charger through I2C. The endianness of the data must be considered during transmission. The I2C_TARGET_ADDRESS is the charger address shown below.


 Transmission
                                        of Data To The Charger Through I2C

Figure 3-8 Transmission of Data To The Charger Through I2C

The code to translate ChargingVoltage() is such to be compatible with the charger.


 Converting
                                        ChargingVoltage() Before Transmission To Charger

Figure 3-9 Converting ChargingVoltage() Before Transmission To Charger

Then, the same TI function shown in Figure 3-8 is called to communicate with the charger.