2
\$\begingroup\$

I am working on a project using an STM32F4 nucleo board and a MLX90621 device. I have a problem regarding the communication between the two using the HAL I2C library.

The EEPROM has two devices inside, an EEPROM and the IR thermal device itself. Using the HAL library with the I2C implementation, I can read the EEPROM perfectly but I cannot read the device itself. I checked with the oscilloscope and the device does not acknowledge when I want to read it. What might be the cause?

I will attach some oscilloscope capture images below and how should they look from the datasheet. Reading whole frame: ReadIR_Real enter image description here

Lack of acknowledge:enter image description here

\$\endgroup\$
  • \$\begingroup\$ Can you improve the signal integrity so there is less crosstalk from SCL to SDA? Is it excessive 10:1 probe ground length of poor GND or actual crosstalk? \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 Apr 1 '18 at 19:38
  • \$\begingroup\$ I am using just one ground for both oscilloscope probe so I think that might be the problem. However, there is something else going on here. When I communicate to the EEPROM, all is good, where the Question Mark is in picture, I have an ACK. I can also see that the device is trying to ACK (I think, because it is trying to go LOW for a moment there) but for some reason it doesn't until the next clock (when it is too late). \$\endgroup\$ – Cezar Chirila Apr 1 '18 at 19:45
  • 1
    \$\begingroup\$ Since SCL is on slow rising edge, signal integrity ought to be improved meanwhile fast falling edge has cross talk \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 Apr 1 '18 at 20:22
  • 1
    \$\begingroup\$ Either way, the problem I think is at the transfer. When comparing my result to the ideal signal in the datasheet there is a major difference. At the transmit sequence using HAL I2C (W60, 02, 00, 04, 40) there is a STOP and a START (where the clock is streched, can be easy seen in second picture), in the datasheet there is only a (re)START. Could this affect the ability of the slave to ACK? Strange enough, the EEPROM is not affected by this. \$\endgroup\$ – Cezar Chirila Apr 1 '18 at 20:24
  • 1
    \$\begingroup\$ There should be no STOP between write address phase and read phase, only extra START. I think this is your problem. \$\endgroup\$ – Ale..chenski Apr 1 '18 at 20:38
2
\$\begingroup\$

According to I2C specifications, when so-called "combined format" is used,

enter image description here

there should be "repeated START" in between configuration stage (internal start and stop addresses, and the number of bytes to read) and READ function, but no STOP.

When the interface encounters STOP, it "forgets" the submitted read parameters, so the next stand-alone READ doesn't know where to read from, and NAKs.

\$\endgroup\$
  • \$\begingroup\$ This was indeed the problem. Modifying the HAL I2C library (specifically, the Mem_Read() function, to take more parameters than just memory location) resulted in a fix. Also, the reason why I could read the EEPROM was that you can read it whole (starting from 0x00) without transmitting anything. \$\endgroup\$ – Cezar Chirila Apr 3 '18 at 14:05
0
\$\begingroup\$

I don't know if this solves your problem, but I can tell from a lot of my own mistakes with I2C that if a slave does not ACK a request, then it's almost always because the I2C slave address is not proper. Please be aware of the fact that the last bit of the first address byte is the R/W bit and often you have to shift the address from the datasheet one bit to the left prior to putting it on the bus.

\$\endgroup\$
  • \$\begingroup\$ Thank you for your input! The address is fine, it is 0x60 as it can be seen in the oscilloscope data (plus the read bit is set). I have left-aligned the address as the HAL library requests and the R/W bit is automatically set. I think I will have to bit bang this. \$\endgroup\$ – Cezar Chirila Apr 1 '18 at 20:45

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.