I2C fallback doesn't work after first failure Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
Post Reply
Tuxford
Posts: 26
Joined: Fri Nov 06, 2020 3:28 pm
Has thanked: 4 times
Been thanked: 4 times

I2C fallback doesn't work after first failure

Post by Tuxford »

I2C driver stop working after first failed command. E.g.

Code: Select all

    uint8_t addr = 0xFF << 1;
    i2cMasterReceiveTimeout(drv, addr, NULL, 0, TIME_S2I(2));

On oscilloscope i have next case. SCL is on low state and that's finish. No operations are allowed until restart of board.
tlv493d.png
tlv493d.png (11.34 KiB) Viewed 6396 times


I have added next fix and failed command doesn't brake I2C anymore.

Code: Select all

diff --git a/os/hal/lib/fallback/I2C/hal_i2c_lld.c b/os/hal/lib/fallback/I2C/hal_i2c_lld.c
index e4ae9a9f9..37b3cb3ed 100644
--- a/os/hal/lib/fallback/I2C/hal_i2c_lld.c
+++ b/os/hal/lib/fallback/I2C/hal_i2c_lld.c
@@ -32,6 +32,8 @@
 
 #define CHECK_ERROR(msg)                                                    \
   if ((msg) < (msg_t)0) {                                                   \
+    palSetLine(i2cp->config->sda);                                          \^M
+    palSetLine(i2cp->config->scl);                                          \^M
     return MSG_TIMEOUT;                                                     \
   }


Any other opinions about this case?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: I2C fallback doesn't work after first failure

Post by Giovanni »

Hi,

Thanks for the patch, moving this topic in "bug reports".

Giovanni
User avatar
FXCoder
Posts: 403
Joined: Sun Jun 12, 2016 4:10 am
Has thanked: 188 times
Been thanked: 134 times

Re: I2C fallback doesn't work after first failure

Post by FXCoder »

Hi,
I use a wrapper API that creates a combined driver allowing mixed H/W and S/W I2C.
One of our team was experiencing this hang for a s/w driven device.

Thanks for the timely fix which saved me all sorts of debug time :-)

--
Bob
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: I2C fallback doesn't work after first failure

Post by Giovanni »

Hi,

Fixed as bug #1224.

Giovanni
Post Reply