Go Down

Topic: Increase clock frequency i2c (Read 399 times) previous topic - next topic

birdm3n

Mar 14, 2018, 10:31 am Last Edit: Mar 14, 2018, 10:51 am by birdm3n
Hi guys! I'm using an arduino m0 pro and I want to increase the clock frequency up to 400kHz or 800kHz.
I need it because I want that the DAC adafruit mcp4725 outputs values with a frequency of 25kHz (the sinewave has a frequency of 100Hz). As the adafruit customer service suggested me I have to increase the frequency rate of the clock SCL because the classical 100kHz are not enough.
I looked around the internet and I found that I need to modify the file twi.h and delete the twi.o file in order to make the library to be recomplied. I can't find the .o file, do you know where can I find it?

Do you know another way to increase the clock frequency for the i2c communication?

MartinL

Hi birdm3n,

You can set the I2C to operate at 400kHz by using the Wire library's setClock() function:

Code: [Select]
Wire.setClock(400000);      // Set the I2C SCL to 400kHz

birdm3n

#2
Mar 14, 2018, 02:49 pm Last Edit: Mar 14, 2018, 02:55 pm by birdm3n
Thanks for the answer! Do you know what is the maximum frequency that I can use in the i2c communication?
Moreover do I have to insert the Wire.setClock() after the Wire.begin() and in the setup function, right?

MartinL

Quote
Do you know what is the maximum frequency that I can use in the i2c communication?
The maximum frequency is usually specified in the slave device's datasheet.

400kHz is the clock speed for I2C fast mode.

Quote
Moreover do I have to insert the Wire.setClock() after the Wire.begin() and in the setup function, right?
Yes, that's right. Just insert Wire.setClock() function after Wire.begin().

Go Up