0
\$\begingroup\$

I design a system with several devices connected to 400kHz I2C interface with wires.

For now, I get shark fins instead of square waves, so I decrease pull up resistors value. The MCU, which drives the I2C communication is STM32F303, and its datasheet states: "I2C Fast mode plus (1 Mbit/s) with 20mA current sink". Does it mean that each pin (Data and Clock) can sink 20mA, and is it sustainable current or short peak value?

I am testing 500 Ohm resistors on my 3.3V system now. 3.3V/500Ohm = 6.6mA. I still get errors and the square is not good enough, I guess. May I go lower, 250 maybe?

Edit: I tried 340 Ohm resistors (around 10mA sink), and it is working for now. Almost no errors (1-2 per minute maybe, under load).

The system has motors, when motor load goes up, errors increase. I am using ferrite rings on the motor lines. Moving motor wires and I2C lines around does not seem to affect anything. I see some noise via oscilloscope. The only thing that affects error count for now is resistors values.

\$\endgroup\$
  • \$\begingroup\$ How long are the data lines? \$\endgroup\$ – po.pe Jul 15 at 9:17
  • \$\begingroup\$ The lines are 50 cm long. \$\endgroup\$ – Roman Simonyan Jul 15 at 9:19
  • \$\begingroup\$ BTW, what do you mean with "the square is not good enough"? I2C still works with non-perfect square wave signals. Are you sure the signal shape is the problem? \$\endgroup\$ – Huisman Jul 15 at 9:21
  • \$\begingroup\$ Lower the resistors I put, more square is the wave, and lower errors count becomes. \$\endgroup\$ – Roman Simonyan Jul 15 at 9:23
  • \$\begingroup\$ If squareness will stop influencing the errors count, I will start searching for other solutions. For now this is only thing I understand that affects the system. \$\endgroup\$ – Roman Simonyan Jul 15 at 9:25
2
\$\begingroup\$

Yes, you could sink up to 20 mA on both I2C ports, but you have to keep the total current in mind.
It is explained in the chapter 6.3.14 I/O port characteristics:

enter image description here

Instead of lowering the pull-up resistors, you could also try if you can somehow lower the bus capacitance.

What do you mean with "the square is not good enough"? I2C still works with non-perfect square wave signals. Are you sure the signal shape is the problem?
Check how non-perfect the squares are in the datasheet:

enter image description here

The only relevant about the signal is the I2C timings specification, given in Table 61 of the datasheet.

\$\endgroup\$
  • \$\begingroup\$ Thank you for the answer. What else can affect the communication? I added more info in the question. May be you can suggest something. \$\endgroup\$ – Roman Simonyan Jul 15 at 9:37
  • \$\begingroup\$ @RomanSimonyan Since moving around the wires doesn't seem to affect anything: is the 3.3V supply stable when the motors turn on? no spikes on it? \$\endgroup\$ – Huisman Jul 15 at 9:41
  • \$\begingroup\$ No nothing changes on the 3.3V line under load. \$\endgroup\$ – Roman Simonyan Jul 15 at 9:51
  • \$\begingroup\$ @RomanSimonyan Well, assuming you're measuring correctly (minimizing the probe loop as e.g. shown in electronics.stackexchange.com/questions/136123/…) try to stabilise the supply using input / output filters on the 3V3 supply as well as to the motor power supply. \$\endgroup\$ – Huisman Jul 15 at 10:03
  • \$\begingroup\$ I remeasured with minimal loop and the 3.3V line is very stable, no changes under load. \$\endgroup\$ – Roman Simonyan Jul 15 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.