Arduino Due I2C at 400kHz shows only 333kHz

Hi

I am working on Arduino Due I2C communication.

I2C frequency on Arduino Due is by default 100 kHz. I verified it using Oscilloscope.
I what to run I2C at 400 kHz. So changed TWI_CLOCK = 400000L at ../arduino-1.5.x/hardware/arduino/sam/libraries/Wire/Wire.h. But, I am not getting exact 400kHz on Oscilloscope. (I am checking SCL pin).

Following is the observation of I2C frequency on Oscilloscope.

I2C Frequency Set | I2C frequency Observed

100 kHz | 100 kHz
200 kHz | 181 kHz
400 kHz | 333 kHz

For default frequency of 100 kHz, observed frequency is correct but for other frequency there is an error which increase with frequency.

Is this the correct way to change the frequency of I2C? What is wrong?

Any response is appreciated. Please reply ASAP.

Thank You in Advance.

Komal

PS: Waveforms at observed frequency is attached.

100kHz.jpg

200kHz.jpg

400kHz.jpg

According to your screenshots the 100kHz signal is also not exactly 100kHz but about 95kHz. As the I2C interface is not asynchronous but synchronous a differing speed is not really relevant. Why do you care about that speed? Do you have an I2C device that needs exactly 400kHz? The code in the IDE is written according to the datasheet of the SAM3ax.