Pixracer does not work with TFMini i2c lidar (ChibiOs)

And do you have screens from STM to compare?

This is with CUAV v5, thus a stm32f7. See that when we are going to read it’s considered a repeated start (Sr) rather than a Start because there wasn’t a stop condition (at least not one grabbed by the resolution of my logic analyzer - I traced at 2MHz).


This looks like the transaction was interrupted or the end of the transaction was not handled correctly, both CLK and SDA just released.
Notice that the last failed LOW timing of the CLK (F) is shorter than normal ones (N)


This part looks similar to my case (#3 in the first post), but I have that interruption after the first byte.
Do transfer() returns any error or it still returns OK?

My tfmini plus arrived to the local post office, so I will have a chance to test it with pixracer stm32f4 in a few days

@lucasdemarchi
Just connected a tfmini plus and have the same issue:

zoomed:

@tridge FYI

@sergey can you connect another sensor like a compass and check we have a stop condition in the trace?

@lucasdemarchi you’re right, tracing compass, there are no stops most of the times (but compass still works OK)

but there we have the stop condition

Only selected have the stop condition, rest haven’t:

Yeah. There’s something wrong with the I2C driver in Chibios I suspect. I was able to force generating the stop condition by using the autoend flag on stm32, but then I’m not getting the interrupt when the transfer ends. I need to find some time to take a look on it again.

Thanks for testing this out.

Later today I will trace compass on Nuttx 3.6 and Chibios 3.6 to see if that a ChibiOS-only issue

Please check mail address, it seems you use incorrect one.

Checked on 3.6.8 NuttX Copter and can confirm every I2C transaction has a trailing stop condition

what do you mean?

@sergbokh thanks a lot for confirming that. This should narrow my bug hunting.

I mean that that this mail seems to be sent to me by mistake, I do not now what is it about.

Plz tell me if I can somehow help diagnosing the issue.
Isn’t it worth to create a ticket to draw some attention to the problem? As it seems the most FC on F4 and F7 MCU are affected.

@sergbokh Can you test with this PR applied? It fixed for me on CUAVv5

2 Likes

@lucasdemarchi TFMini Plus works now on PixRacer too. Thank you for getting to the bottom of this!

Next step could be to check my driver for TFmini v1 i2c to see if your i2c fix also helps there.

The one thing I cannot understand - this isn’t a ChibiOs bug, right? This looks like a some problem with AP_HAL_ChibiOS/I2CDevice.cpp design. So we need for a i2cSoftStop() to workaround.

@lucasdemarchi pretty impressive job here :+1:
Looking at the PR is like a Chibios training guide on how to write a driver

1 Like

Premature i2c bus stopping likely also could be the root cause of my problem with TS100 compass

That was also workaround by @tridge with

but now the root cause should be fixed.

did that worked with tfmini lidar i2c ?

You mean non-Plus version, right?
Technically it can, but there is no driver for it in ArduCopter.