Hello. Using the wire library you are able to set up your i2c bus speed. I would like to know if this is the only values that can be used and if they are valid for this specific board:
TWBR prescaler Frequency
12 1 400 kHz (the maximum supported frequency)
32 1 200 kHz
72 1 100 kHz (the default)
152 1 50 kHz
78 4 25 kHz
158 4 12.5 kHz
The second thing that I don't really understand is if this i2c frequency is similar to the uart one (rx tx serial) - for example connecting two devices with different baudrates will 100% fail transmitting or receiving one from / to another.
I'm asking this because I don't use much data on the bus and a low frequency will give me a better square wave signal. But in my system there is an i2c device (pcf8547) on which I have no control to change the frequency. Is it ok to lower the i2c frequency if the pcf8547 has a different default one?
I2C is a synchronous bus, UART works Asynchronously as the name suggests.
On an I2C bus the master generates the clock signal and dictates the maximum frequency. But the slave can stretch the low clock pulse if it cannot handle the stream at a higher frequency. This way you get the best from two worlds, sync and async
I'm afraid I don't fully understand. Could you please send me some reference for a better understanding. Also, what happens for example if you have a communication slave to slave? Who dictates the clock? (thanks for the fast response).
Only a master can start a communication, slave-slave is not an option. If a device wants to send information, it does so in master mode. If a device wants to receive information, it does so in master mode. The addressed device reacts in slave mode, even if it also could behave as a master.
I'm having some issues and it might be some of the many i've read on this forum: the length of the wire (about 50cm) the fact that it;s a twisted wire, the pullups not well chosen, the baudrate. Therefore I want to reduce the baud rate, and one by one fix all the problems. Because I only send one byte at a time and my app is not time depended but consistency dependent, I am ready to trade speed for consistency.