# ATmega16u4 and ATmega32u4 i2c bug in Proteus AVR model?

I am trying to use i2c with ATmega16u4/ATmega32u4 in Proteus (version 8.5 SP1) and in my i2c code the following code line hangs the MCU:

while(wait && (TWI_MTX == twi_state)){


It never gets past this. Doing some debugging I verified that TWCR never changes in the Proteus simulation, so it is impossible to enable i2c, which is the cause of this hang.

I tried setting it directly, with TWCR=0xFF just for testing, but register value never changes, it is always 0 during the entire simulation. If I do the same thing on ATmega328p the register does change successfully.

If I upload the code to a physical processor it works fine. If I use the same code on ATmega328p simulation in Proteus, it also works.

This is not a pull up resistor or communication issue. I have 4.7k digital pull ups connected, but the thing is, the pins never get to change states in the first place, because I cant get the MCU to set i2c enable registers.

This looks to me like a Proteus model problem or bug. Has anyone got ATmega32u4 to work with i2c in Proteus simulation?