I finally got a chance to actually try this.
If I say:
Wire.begin(); // set up I2C comms
TWSR &= 0xFC; // set I2C frequency of 400K
TWBR = 12;
uint32_t i2c_prescaler = 4 ^ (TWSR & 0x03);
uint32_t i2c_freq = 16000000L / (16 + 2 * TWBR * i2c_prescaler);
and then later on
serial_printf("i2c=%d\n", (int) (i2c_freq / 1000))
It prints [b]142[/b] instead of the expected [b]400[/b].
If I put the [b]Wire.begin()[/b] after the two register setting lines instead of before them, I get [b]27[/b] instead of the expected [b]400[/b].
What am I doing wrong?