1
\$\begingroup\$

I'm currently try to use the MS5611 (sitting on a CJMCU-117) over I²C with libopencm3 on a STM32F103C8.

When I do a read, the slave sends an additional byte (0xFF) after the master has send a NACK. This happens for the PROM readout (2 bytes) as well as for the ADC readout (3 bytes).

The following Code results in the following waveform, the datasheet [1] shows on page 13 how it should look like.

// Send
i2c_transfer7(I2C2, 0x77,
    commandPtr, 1,
    nullptr, 0);

// Read
i2c_transfer7(I2C2, 0x77,
    nullptr, 0,
    bufferPtr, 3);

Waveform

Can anybody help me how to solve this?

[1] https://www.te.com/commerce/DocumentDelivery/DDEController?Action=showdoc&DocId=Data+Sheet%7FMS5611-01BA03%7FB3%7Fpdf%7FEnglish%7FENG_DS_MS5611-01BA03_B3.pdf

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Check your code. It looks like the master is doing an additional read, that is not an issue with the device being addressed. \$\endgroup\$ Commented Nov 7, 2018 at 16:54
  • 1
    \$\begingroup\$ The slave does not send anything by itself. It's the master that clocks the extra byte. Typical STM32F1xx coding error by the way, people asked about this on various STM32 forums at least 10 years ago already. \$\endgroup\$
    – Justme
    Commented Nov 7, 2018 at 17:42
  • \$\begingroup\$ Thanks guys, that makes sense. Since I was just relying on the i2c_transfer7 function of libopencm3, I couldn't really see room for error there. But now I had a look at it and it seems like it is not following the protocol of the reference manual. I implemented it myself now and this seems to work. \$\endgroup\$
    – Tonke
    Commented Nov 8, 2018 at 14:45

1 Answer 1

1
\$\begingroup\$

The i2c_transfer7 function of libopencm3 is implemented using I2C with polling, but isn't following the STM32 Reference manual (RM0008, Page 759, Method 2), which states special handling of 1 and 2 byte receives. This results in clearing the ACK-bit at the wrong time.

See http://libopencm3.org/docs/latest/stm32f2/html/i2c__common__v1_8c_source.html#l00492

\$\endgroup\$
1
  • \$\begingroup\$ That is not an answer. Not behaving how? What is the difference between what it is doing vs. what the reference manual says it should be doing?? \$\endgroup\$ Commented Nov 27, 2018 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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