It never gets past this.
Doing some debugging I verified that TWCR never changes in this model, 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.
If I do the same thing on ATmega328p the register does change.
If I upload the code to a physical processor it works.
If I use the same code on ATmega328p simulation in Proteus, it also works.
This looks to me like a Proteus model problem or bug.
Has anyone got ATmega32u4 to work with i2c in Proteuus simulation?
I have 4.7 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. SDA and SCL are always LOW.
ATmega16u4 has the same problem, but ATmega328p works fine, TWCR register can be changed and i2c works as it should.