I am using the MAX17043 Battery gauge on my custom ATMEGA32U4 board to log my battery usage. The communication with the device is done over the I2C/TWI interface.
I am using Peter Fleury's I2C driver. The ATMEGA32U4 runs at 1MHz and the I2C SCL frequency is 400kHz. I am using external pull-ups(4.7kOhms)
Here is the issue:
I am either completely not able to communicate with the device or the communication breaks-off randomly after a few bytes. Whatever data I am getting during those lucky transmissions are not garbage but actual voltage measurements of the battery.
As the ATMEGA32U4 datasheet suggests, for a stable operation, the TWBR value should be greater than 10.
TWBR = ((F_CPU/SCL_CLOCK)-16)/(2 * 4^TWSR);
Plugging in the above values in the equation(TWSR is 0), I am getting a value of -6.75 for the TWBR.
This clearly shows that the I2C will not operate in a stable manner.
I also tried different SCL frequencies ranging between 10kHz and sub-400kHz, but they don't even work as before.
This is equally strange because I interface the Bosch BNO055 IMU on the same bus and it works without any issues.
(I compared the datasheet of both devices and they have similar timing requirements for the I2C communication)
So, what could be the likely solution to the problem be?
Will operating the ATMEGA32U4 @ say 8MHz solve the issue?
Or is there something else I should take care of?
Thanks in advance.
[P.S.: Before anyone is suggesting me to sniff the I2C bus using a logic analyser/scope, I want to let you know that I don't have one :(]