cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4-DISCOVERY I2C hanging problem

QDang
Associate

Hi everyone,

I have a strange behavior with STM32F4-DISCOVERY I2C communication.

My system includes an STM32F4-DISCOVERY, a BLDC motor, a flow sensor (SDP601), and a pressure sensor (MS5525DSO). The motor works as a blower and 2 sensors measure the flow and pressure from the tube. 2 sensors share a same I2C line (PORTB PinsPack 3) since they have different slave addresses.

I have no problem with reading the flow sensor. Also there's no problem when reading the pressure sensor when the BLDC motor runs at a low speed. The problem comes when the motor runs at higher speeds: after a while, SDA line is pulled low and there's no way to recover it (I have manually set the GPIO pin high, sent I2C_START/STOP command, or reset the I2C module).

0690X000006DkTxQAK.jpg

When I zoomed in, it seems that the SDL (blue) is pulled low before the SCL falling edge. This bug always happens after MCU sends the slave address (0x77) when I try to send 0x00 to the pressure sensor. I don't know if it that makes a START condition in the line so the communication was hung or not.

0690X000006DkU2QAK.jpg

When reading well, that signal is like this:0690X000006DkU7QAK.jpg

It is strange that it only happens when I send some specific commands such as 0x00 ("Start reading" command). But when I send 0x40 or 0x42 or 0x44 ("Start conversion" command), there was no problem.

Could anyone suggest any problem? I have checked the supply voltage during the failure but there was no problem. I also can't find any glitching signal. I'm running the I2C module at 10K Hz, sensors supply voltage 3V (from STM32F4-DISC board). The power source for BLDC motor is from a 24V adapter which is separated from the MCU power source (from PC). However, they share the same GND.

Moreover, my original board used an ATMega328 chip and the system worked very well. I removed this MCU and used STM32F4_DISC with some wires connecting out (I2C, SPI wires). The I2C wires from the board to the sensors (including lines in the PCB) are short I think. They are less than 20 cm.

Thank you in advance!

2 REPLIES 2
S.Ma
Principal

For debug purpose:

  1. Make sure all the I2C traffic is coming from the same code place. No I2C message within interrupts.
  2. Use my GPIO I2C code shared in this forum to test. It includes error recovery management.

Thank you for your prompt reply. The bug happens at a same place. Whenever I send 0x00 command to the pressure sensor, the communication hangs right after the slave address (0x77 or 0b1110111) is sent. As you can see from the picture 1 and 2, the problem occurs the last bit "1" in the SDA line.

I also tried debugging in the main loop and it happened at the same place.