No I2C feedback: How to debug?

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: No I2C feedback: How to debug?

Post by Roberthh » Sun May 01, 2022 5:48 am

I think it's time to use your logic analyzer to see, if clock and data signals are regular and whether the chip uses clock stretching. That is not supported by the Pico. You can try to use SoftI2C instead, which supports clock stretching. For a strange reason, SoftI2C works faster that hard I2C on the Pico. if set to 400kHz freq, I see 250kHz with hard I2C and 500kHz with SoftI2C.

User avatar
wintifrosch
Posts: 12
Joined: Sun Mar 20, 2022 9:37 am
Location: Winterthur, Switzerland
Contact:

Re: No I2C feedback: How to debug?

Post by wintifrosch » Sun May 01, 2022 12:10 pm

@Roberthh: Thank you for your support! I think it's time to use your logic analyzer
➝ I ordered an LA104, will take a week or so.
➝ I'll attend a hackerspace meeting tomorrow. Maybe I'll get learnings there.

With additional external power supply (EPS): stable 3.28V idle and during tests. However, results still depend on both, i2c frequency and i2c.status() poll delay. I resoldered the board pins: no improvement. I tried the spare PN532 board: same results.

PN532 test with connected EPS (board 1):

Code: Select all

delay=0.40 (real:0.4167s) freq=50_000: [[36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=0.80 (real:0.8333s) freq=50_000: [[36], [36], [36], [], [36], [36], [36], [], [36], [36], [36], []]
delay=1.60 (real:1.6667s) freq=50_000: [[], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=3.20 (real:3.2500s) freq=50_000: [[36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=6.40 (real:6.4167s) freq=50_000: [[36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]

delay=0.40 (real:0.4167s) freq=100_000: [[36], [36], [], [36], [], [36], [], [36], [], [36], [], [36]]
delay=0.80 (real:0.8333s) freq=100_000: [[36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=1.60 (real:1.5833s) freq=100_000: [[36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=3.20 (real:3.2500s) freq=100_000: [[36], [36], [36], [], [], [], [], [], [], [], [], []]
delay=6.40 (real:6.4167s) freq=100_000: [[36], [36], [], [36], [36], [36], [36], [36], [36], [], [36], [36]]

delay=0.40 (real:0.4167s) freq=200_000: [[], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=0.80 (real:0.8333s) freq=200_000: [[36], [], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=1.60 (real:1.5833s) freq=200_000: [[36], [], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=3.20 (real:3.1667s) freq=200_000: [[], [36], [], [], [], [], [], [], [], [], [], []]
delay=6.40 (real:6.4167s) freq=200_000: [[], [], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]

delay=0.40 (real:0.4167s) freq=400_000: [[36], [36], [], [], [], [], [], [], [], [], [], []]
delay=0.80 (real:0.8333s) freq=400_000: [[], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=1.60 (real:1.5833s) freq=400_000: [[36], [36], [], [36], [36], [], [36], [36], [36], [], [36], [36]]
delay=3.20 (real:3.2500s) freq=400_000: [[36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=6.40 (real:6.4167s) freq=400_000: [[36], [36], [], [], [], [], [], [], [], [], [], []]
PN532 test with disconnected EPS, breadboard power supply board still mounted (3.27–3.29V during test, board 1):

Code: Select all

delay=0.40 (real:0.4167s) freq=50_000: [[36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=0.80 (real:0.8333s) freq=50_000: [[36], [36], [36], [], [36], [36], [36], [], [36], [36], [36], []]
delay=1.60 (real:1.6667s) freq=50_000: [[36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=3.20 (real:3.1667s) freq=50_000: [[36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=6.40 (real:6.5000s) freq=50_000: [[36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]

delay=0.40 (real:0.4167s) freq=100_000: [[36], [36], [], [36], [], [36], [36], [36], [36], [], [36], [36]]
delay=0.80 (real:0.7500s) freq=100_000: [[36], [], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=1.60 (real:1.6667s) freq=100_000: [[], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=3.20 (real:3.1667s) freq=100_000: [[36], [36], [36], [36], [], [], [], [], [], [], [], []]
delay=6.40 (real:6.4167s) freq=100_000: [[36], [36], [], [36], [36], [], [36], [36], [36], [], [36], [36]]

delay=0.40 (real:0.3333s) freq=200_000: [[36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=0.80 (real:0.8333s) freq=200_000: [[36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=1.60 (real:1.6667s) freq=200_000: [[], [], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=3.20 (real:3.1667s) freq=200_000: [[36], [36], [], [], [36], [], [], [], [36], [], [], []]
delay=6.40 (real:6.4167s) freq=200_000: [[36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]

delay=0.40 (real:0.4167s) freq=400_000: [[36], [36], [], [], [], [], [], [], [], [], [], []]
delay=0.80 (real:0.8333s) freq=400_000: [[36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=1.60 (real:1.5833s) freq=400_000: [[36], [36], [], [36], [36], [], [36], [36], [36], [], [36], [36]]
delay=3.20 (real:3.1667s) freq=400_000: [[], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=6.40 (real:6.4167s) freq=400_000: [[36], [36], [], [], [], [], [], [], [], [], [], []]
PN532 test with disconnected EPS, breadboard power supply board still mounted (board 1 resoldered):

Code: Select all

delay=0.40 (real:0.4167s) freq=50_000: [[], [36], [36], [36], [36], [36], [], [], [36], [36], [36], [36]]
delay=0.80 (real:0.8333s) freq=50_000: [[], [], [36], [36], [36], [36], [36], [36], [], [], [], []]
delay=1.60 (real:1.6667s) freq=50_000: [[], [36], [], [36], [], [36], [], [36], [], [36], [], [36]]
delay=3.20 (real:3.1667s) freq=50_000: [[], [], [36], [], [36], [36], [], [36], [], [36], [36], []]
delay=6.40 (real:6.5000s) freq=50_000: [[36], [36], [36], [36], [36], [36], [], [], [], [], [], [36]]

delay=0.40 (real:0.4167s) freq=100_000: [[], [36], [36], [], [36], [36], [], [36], [36], [], [36], [36]]
delay=0.80 (real:0.8333s) freq=100_000: [[], [36], [36], [36], [36], [36], [36], [36], [], [], [36], [36]]
delay=1.60 (real:1.5833s) freq=100_000: [[36], [36], [], [36], [36], [], [36], [36], [], [36], [36], []]
delay=3.20 (real:3.2500s) freq=100_000: [[], [], [], [36], [36], [36], [], [], [], [], [36], [36]]
delay=6.40 (real:6.4167s) freq=100_000: [[36], [36], [36], [36], [36], [36], [], [], [36], [36], [36], [36]]

delay=0.40 (real:0.4167s) freq=200_000: [[36], [], [36], [36], [], [36], [36], [], [36], [36], [], [36]]
delay=0.80 (real:0.7500s) freq=200_000: [[36], [], [36], [], [36], [], [36], [], [36], [], [36], []]
delay=1.60 (real:1.6667s) freq=200_000: [[36], [36], [36], [36], [36], [36], [36], [36], [36], [], [], []]
delay=3.20 (real:3.1667s) freq=200_000: [[36], [36], [36], [36], [36], [36], [], [36], [36], [36], [36], [36]]
delay=6.40 (real:6.4167s) freq=200_000: [[36], [], [36], [], [36], [], [36], [], [36], [], [36], []]

delay=0.40 (real:0.4167s) freq=400_000: [[36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=0.80 (real:0.8333s) freq=400_000: [[], [], [], [], [], [], [], [], [], [], [], []]
delay=1.60 (real:1.5833s) freq=400_000: [[], [36], [], [36], [], [36], [], [36], [], [36], [], [36]]
delay=3.20 (real:3.1667s) freq=400_000: [[], [36], [36], [36], [36], [], [36], [], [36], [36], [36], [36]]
delay=6.40 (real:6.4167s) freq=400_000: [[], [], [], [], [], [], [], [], [], [], [], []]
PN532 test with disconnected EPS, but breadboard power supply board still mounted (3.31–3.35V during tests, board 2):

Code: Select all

delay=0.40 (real:0.4167s) freq=50_000: [[], [36], [36], [36], [36], [36], [], [], [36], [36], [36], [36]]
delay=0.80 (real:0.8333s) freq=50_000: [[], [], [36], [36], [36], [36], [36], [36], [], [], [], []]
delay=1.60 (real:1.6667s) freq=50_000: [[], [36], [], [36], [], [36], [], [36], [], [36], [], [36]]
delay=3.20 (real:3.2500s) freq=50_000: [[], [], [36], [], [36], [36], [], [36], [36], [], [36], []]
delay=6.40 (real:6.4167s) freq=50_000: [[], [], [], [36], [36], [36], [36], [36], [36], [], [], []]

delay=0.40 (real:0.4167s) freq=100_000: [[36], [36], [], [36], [36], [], [36], [36], [], [36], [36], []]
delay=0.80 (real:0.8333s) freq=100_000: [[36], [36], [36], [36], [], [], [36], [36], [36], [36], [36], [36]]
delay=1.60 (real:1.5833s) freq=100_000: [[], [36], [36], [], [36], [36], [], [36], [36], [], [36], [36]]
delay=3.20 (real:3.2500s) freq=100_000: [[36], [], [], [], [36], [36], [36], [], [], [], [], [36]]
delay=6.40 (real:6.4167s) freq=100_000: [[36], [36], [], [], [36], [36], [36], [36], [36], [36], [36], [36]]

delay=0.40 (real:0.4167s) freq=200_000: [[36], [], [36], [36], [], [36], [36], [], [36], [36], [], [36]]
delay=0.80 (real:0.8333s) freq=200_000: [[36], [], [36], [], [36], [], [36], [], [36], [], [36], []]
delay=1.60 (real:1.5833s) freq=200_000: [[36], [36], [36], [36], [36], [36], [36], [36], [36], [], [], []]
delay=3.20 (real:3.1667s) freq=200_000: [[36], [36], [36], [36], [36], [], [36], [36], [36], [36], [36], [36]]
delay=6.40 (real:6.4167s) freq=200_000: [[], [36], [], [36], [], [36], [], [36], [], [36], [], [36]]

delay=0.40 (real:0.4167s) freq=400_000: [[], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=0.80 (real:0.8333s) freq=400_000: [[36], [36], [36], [], [], [], [], [], [], [], [], []]
delay=1.60 (real:1.5833s) freq=400_000: [[], [36], [], [36], [], [36], [], [36], [], [36], [], [36]]
delay=3.20 (real:3.2500s) freq=400_000: [[], [36], [36], [36], [36], [], [36], [36], [36], [36], [36], [36]]
delay=6.40 (real:6.4167s) freq=400_000: [[], [], [], [], [], [], [], [], [], [], [], []]
Same test with another I2C board show flawless i2c.scan() results, as expected (VCNL4040 proximity sensor):

Code: Select all

delay=0.40 (real:0.5000s) freq=50_000: [[96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96]]
delay=0.80 (real:0.8333s) freq=50_000: [[96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96]]
delay=1.60 (real:1.5833s) freq=50_000: [[96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96]]
delay=3.20 (real:3.2500s) freq=50_000: [[96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96]]
delay=6.40 (real:6.4167s) freq=50_000: [[96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96]]

delay=0.40 (real:0.4167s) freq=100_000: [[96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96]]
delay=0.80 (real:0.8333s) freq=100_000: [[96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96]]
delay=1.60 (real:1.6667s) freq=100_000: [[96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96]]
delay=3.20 (real:3.1667s) freq=100_000: [[96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96]]
delay=6.40 (real:6.4167s) freq=100_000: [[96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96]]

delay=0.40 (real:0.4167s) freq=200_000: [[96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96]]
delay=0.80 (real:0.8333s) freq=200_000: [[96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96]]
delay=1.60 (real:1.5833s) freq=200_000: [[96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96]]
delay=3.20 (real:3.2500s) freq=200_000: [[96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96]]
delay=6.40 (real:6.4167s) freq=200_000: [[96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96]]

delay=0.40 (real:0.4167s) freq=400_000: [[96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96]]
delay=0.80 (real:0.7500s) freq=400_000: [[96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96]]
delay=1.60 (real:1.5833s) freq=400_000: [[96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96]]
delay=3.20 (real:3.2500s) freq=400_000: [[96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96]]
delay=6.40 (real:6.4167s) freq=400_000: [[96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96], [96]]

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: No I2C feedback: How to debug?

Post by Roberthh » Sun May 01, 2022 1:15 pm

Did you try SoftI2C?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: No I2C feedback: How to debug?

Post by Roberthh » Sun May 01, 2022 1:17 pm

The other board used a different sensor. So you cannot compare the test result.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: No I2C feedback: How to debug?

Post by Roberthh » Sun May 01, 2022 1:43 pm

Many people use these simple logic analyzers. Sample Link: https://www.amazon.de/AZDelivery-%E2%AD ... r=8-6&th=1
Together with the Saleae Logic software or Open Source Pulseview. Very handy.

User avatar
wintifrosch
Posts: 12
Joined: Sun Mar 20, 2022 9:37 am
Location: Winterthur, Switzerland
Contact:

Re: No I2C feedback: How to debug?

Post by wintifrosch » Sun May 01, 2022 5:11 pm

«Did you try SoftI2C?»
➝ Same results (see below)

«The other board used a different sensor. So you cannot compare the test result.»
➝ This was the tests aim: to prove that the hard- and software test setup besides the PN532 board will work fine for i2C.scan(). Test successful.

«…logic analyzers»
➝ Ordered an LA104 4 channel logic analyzer. Will postpone further tests, unless new inputs suggest otherwise.

PN532 test with board 2 and SoftI2C. Same inconsistent results.

Code: Select all

i2c = SoftI2C(sda=Pin(4), scl=Pin(5), freq=freq)
...
delay=0.40 (real:0.4167s) freq=50_000: [[], [36], [36], [36], [], [36], [], [36], [], [36], [], [36]]
delay=0.80 (real:0.8333s) freq=50_000: [[36], [36], [], [36], [36], [36], [], [36], [36], [], [], [36]]
delay=1.60 (real:1.6667s) freq=50_000: [[], [], [36], [36], [36], [36], [], [], [], [36], [36], [36]]
delay=3.20 (real:3.2500s) freq=50_000: [[36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=6.40 (real:6.4167s) freq=50_000: [[36], [36], [], [36], [36], [36], [], [36], [36], [], [], [36]]

delay=0.40 (real:0.4167s) freq=100_000: [[36], [], [36], [36], [], [], [36], [36], [], [36], [36], []]
delay=0.80 (real:0.8333s) freq=100_000: [[], [36], [], [36], [], [36], [], [36], [], [36], [], [36]]
delay=1.60 (real:1.5833s) freq=100_000: [[36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=3.20 (real:3.2500s) freq=100_000: [[36], [36], [], [36], [36], [36], [36], [], [36], [36], [36], [36]]
delay=6.40 (real:6.4167s) freq=100_000: [[], [36], [], [36], [], [36], [], [36], [], [36], [], [36]]

delay=0.40 (real:0.3333s) freq=200_000: [[36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36], [36]]
delay=0.80 (real:0.8333s) freq=200_000: [[36], [36], [], [], [], [], [], [], [], [], [], []]
delay=1.60 (real:1.5833s) freq=200_000: [[], [36], [], [36], [36], [], [36], [], [36], [36], [], [36]]
delay=3.20 (real:3.2500s) freq=200_000: [[], [36], [], [36], [], [36], [], [36], [], [36], [], [36]]
delay=6.40 (real:6.4167s) freq=200_000: [[36], [], [], [], [], [], [], [], [], [], [], []]

delay=0.40 (real:0.4167s) freq=400_000: [[], [36], [], [36], [], [36], [], [36], [], [36], [], [36]]
delay=0.80 (real:0.7500s) freq=400_000: [[], [36], [36], [36], [], [36], [36], [36], [], [36], [36], [36]]
delay=1.60 (real:1.6667s) freq=400_000: [[], [], [], [], [], [], [], [], [], [], [], []]
delay=3.20 (real:3.1667s) freq=400_000: [[], [], [], [], [], [], [], [], [], [], [], []]
delay=6.40 (real:6.4167s) freq=400_000: [[36], [36], [36], [36], [], [36], [36], [36], [], [36], [36], [36]]

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: No I2C feedback: How to debug?

Post by Roberthh » Sun May 01, 2022 7:16 pm

so:
- a different chip at that board works fine. So the hardware of the Pico and the wiring is OK.
- Using SoftI2C gives the same pattern. This clock stretching seems not to be the problem.

Not much left besides the target board.

User avatar
wintifrosch
Posts: 12
Joined: Sun Mar 20, 2022 9:37 am
Location: Winterthur, Switzerland
Contact:

Re: No I2C feedback: How to debug?

Post by wintifrosch » Sun May 01, 2022 7:50 pm

Agree.
I ordered another two PN532 boards from another supplier. HTH.

User avatar
wintifrosch
Posts: 12
Joined: Sun Mar 20, 2022 9:37 am
Location: Winterthur, Switzerland
Contact:

Re: No I2C feedback: How to debug?

Post by wintifrosch » Fri May 06, 2022 9:02 pm

Received the logic analyzer. Here's what I've learned up to now:
  • PICO's I2C timing is not very constant, especially in high frequencies.
  • After pulling SDA to LOW in the ACK pulse, the PN532 keeps the signal LOW for a long time (0.3ms or more. sometimes the signal even remains LOW (Screenshot Ⓞ below). It's a pity I don't have an analog oscilloscope to observe the power levels on SDA and SCL.
  • The color display of the mini ware LA104 logic analyzer is to small to analyse more than a couple of bytes. I downloaded the csv data and built an I2C interpreter in Excel.
Up to now, I just simulated a short portion of the i2c.scan(), where only the address is send and 0 bytes are exchanged. a couple of tests are depicted in the screenshots below.
In a few days, I'll post observations during a longer communication, with focus on PN532s long ACK signals.
_______________________________
VCNL4040 reference board, freq=100_000, Hardware I2C: arrhythmic patterns now and then. 30–180ns per byte. Snapshot Ⓓ was 10x faster than usual (▲T is the time between the two dotted lines, from MSB to ACK).
Image

VCNL4040 reference board, freq=100_000, Software I2C: similar to Hardware I2C.
Image

VCNL4040 reference board, freq=10_000: ~1ms per byte, but reliable pulse on SCL in both modes (images from SoftI2C)
Image

PN532 RFID board, freq=100_000, Hardware I2C: arrhythmic now and then (Ⓜ︎ is zoomed in to see the first bit, ACK is on the right far outside the screen), after ACK pulse (=rightmost white dotted line), SDA is pulled LOW for 300µs or longer, probably by PN532. In Ⓞ SDA didn't return to HIGH within the sampling period.
Image

Post Reply