1.2. Using a Supported Altera Device to Interface with a I2C Battery Gauge
In this implementation, the battery gauge acts as slave to the supported Altera device and has a software programmable address. At any time, the supported Altera device acting as the master can read the exact state of battery charge through the battery gauge interface. The design uses an inexpensive battery gauge device, such as the Maxim DS2745.
Because the design is made for illustration, it does not implement a complete I2C master. This design, therefore, does not accommodate multimaster capability and is only meant to demonstrate the capability of the supported Altera device to read the DS2745 battery gauge via an I2C interface.
|I2C Serial Data
In order to retrieve the status of the battery from the gauge, the master initiates the communication cycle by sending a Start condition on the bus. The Start condition, which consists of pulling the SDA line low while SCL is high, is followed by a 7-bit slave address and a write command (90h). After receiving these signals, the slave sends back an acknowledgment to the master.
After receiving the acknowledgment (battery gauge DS2745), the master sends the memory address (0Ch), which corresponds to the voltage register on the slave. The DS2745 acknowledges this memory address, and then the master generates a Repeat Start (Sr). After the Repeat Start, the supported Altera device (master) sends the device address again, followed by a read, this time (91h). The DS2745 acknowledges it as the same. The battery data is transferred on the SDA line to the master in the next two 8-bit read operations; the MSB is sent first followed by the LSBs. The master sends an acknowledgment after every 8 bits that are received. A Stop (P) condition is generated by the master by leaving the SDA line high when SCL is high after the read is complete. The slave returns Data in two's complement form, which is converted to a bar form for display.