Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.arch.embedded > #30121

Re: I2C Single Master: peripheral or bit banging?

From David Brown <david.brown@hesbynett.no>
Newsgroups comp.arch.embedded
Subject Re: I2C Single Master: peripheral or bit banging?
Date 2020-11-22 19:44 +0100
Organization A noiseless patient Spider
Message-ID <rpebja$lbr$1@dont-email.me> (permalink)
References (3 earlier) <rp8n5k$k5f$1@dont-email.me> <rp8r4d$lns$1@dont-email.me> <rp8uvt$mbe$1@dont-email.me> <rpasch$im9$1@dont-email.me> <rpe4pg$3qr$1@dont-email.me>

Show all headers | View raw


On 22/11/2020 17:48, pozz wrote:
> Il 21/11/2020 12:06, David Brown ha scritto:
>> On 20/11/2020 18:39, Tauno Voipio wrote:
>>
>>> I have had thousands of industrial instruments in the field for decades,
>>> each running some internal units with I2C, some bit-banged and others
>>> on the hardware interfaces on the processors used, and not a single
>>> failure due to I2C hanging.
>>>
>>
>> The only time I have seen I²C buses hanging is during development, when
>> you might be re-starting the cpu in the middle of an operation without
>> there being a power-on reset to the slave devices.  That can easily
>> leave the bus in an invalid state, or leave a slave state machine out of
>> synchronisation with the bus.  But I have not seen this kind of thing
>> happen in a live system.
> In the past I had a big problem with a I2C bus on a board. Ubiquitous
> EEPROM 24LC64 connected to a 16-bits MCU by Fujitsu. In that case, I2C
> was implemented by a bit-bang code.
> 
> At startup MCU read the EEPROM content and if it was corrupted, factory
> default are used and wrote to the EEPROM. This mechanism was introduced
> to write a blank EEPROM at the very first power up of a fresh board.
> 
> Unfortunately it sometimes happened that the MCU reset in the middle of
> a I2C transaction with the EEPROM (the reset was caused by a glitch on
> the power supply that triggered a MCU voltage supervisor).
> When the MCU restarted, it tried to communicate with the EEPROM, but it
> was in a not synchronized I2C state. This is well described in AN868[1]
> from Analog Devices..
> 
> The MCU thoughts it was a blank EEPROM and factory settings was used,
> overwriting user settings! What the user blamed was that the machine
> sometimes restarted with factory settings, losing user settings.
> 
> In that case the solution was adding a I2C reset procedure at startup
> (some clock pulses and STOP condition as described in the Application
> Note).
> I think this I2C bus reset procedure must be always added where there's
> a I2C bus and most probably it must be implemented by a big-bang code.
> 
> 
> [1]
> https://www.analog.com/media/en/technical-documentation/application-notes/54305147357414AN686_0.pdf
> 

Sure, add that kind of a reset at startup - it also helps if you are
unlucky when restarting the chip during development.

Also make sure you write two copies of the user data to the EEPROM, so
that you can survive a crash while writing to it.

But if your board is suffering power supply glitches that are enough to
trigger the MCU brown-out, but not enough to cause a proper re-start of
the rest of the board, then /that/ is a major problem that you should be
trying to solve.

> 
>>> Please remember that the I2C bus is an Inter-IC bus, not to be used for
>>> connections to the outside of the device, preferably only on the same
>>> circuit board. There should be no external connectors where e.g. the
>>> shorts between the SCL and SDA could happen.
>>>
>>> All the hardWare I2C controls have been able to be restored to a
>>> sensible state with a software reset after a time-out. This includes
>>> the Atmel chips.
>>>
>>

Back to comp.arch.embedded | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

I2C Single Master: peripheral or bit banging? pozz <pozzugno@gmail.com> - 2020-11-20 09:43 +0100
  Re: I2C Single Master: peripheral or bit banging? Bernd Linsel <bl1@gmx.com> - 2020-11-20 11:38 +0100
    Re: I2C Single Master: peripheral or bit banging? pozz <pozzugno@gmail.com> - 2020-11-20 12:45 +0100
      Re: I2C Single Master: peripheral or bit banging? Bernd Linsel <bl1@gmx.com> - 2020-11-20 15:57 +0100
  Re: I2C Single Master: peripheral or bit banging? Richard Damon <Richard@Damon-Family.org> - 2020-11-20 08:09 -0500
    Re: I2C Single Master: peripheral or bit banging? pozz <pozzugno@gmail.com> - 2020-11-20 15:15 +0100
      Re: I2C Single Master: peripheral or bit banging? Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2020-11-20 17:25 +0200
        Re: I2C Single Master: peripheral or bit banging? pozz <pozzugno@gmail.com> - 2020-11-20 17:33 +0100
          Re: I2C Single Master: peripheral or bit banging? Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2020-11-20 19:39 +0200
            Re: I2C Single Master: peripheral or bit banging? Dimiter_Popoff <dp@tgi-sci.com> - 2020-11-20 23:25 +0200
              Re: I2C Single Master: peripheral or bit banging? Grant Edwards <invalid@invalid.invalid> - 2020-11-20 23:09 +0000
                Re: I2C Single Master: peripheral or bit banging? Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2020-11-21 11:46 +0200
            Re: I2C Single Master: peripheral or bit banging? David Brown <david.brown@hesbynett.no> - 2020-11-21 12:06 +0100
              Re: I2C Single Master: peripheral or bit banging? pozz <pozzugno@gmail.com> - 2020-11-22 17:48 +0100
                Re: I2C Single Master: peripheral or bit banging? David Brown <david.brown@hesbynett.no> - 2020-11-22 19:44 +0100
                Re: I2C Single Master: peripheral or bit banging? pozz <pozzugno@gmail.com> - 2020-11-23 08:44 +0100
                Re: I2C Single Master: peripheral or bit banging? David Brown <david.brown@hesbynett.no> - 2020-11-23 09:42 +0100
                Re: I2C Single Master: peripheral or bit banging? David Brown <david.brown@hesbynett.no> - 2020-11-23 09:44 +0100
                Re: I2C Single Master: peripheral or bit banging? Richard Damon <Richard@Damon-Family.org> - 2020-11-23 07:25 -0500
                Re: I2C Single Master: peripheral or bit banging? Reinhardt Behm <rbehm@hushmail.com> - 2020-11-24 18:15 +0800
  Re: I2C Single Master: peripheral or bit banging? stephen@mpeforth.com (Stephen Pelc) - 2020-11-20 14:53 +0000
  Re: I2C Single Master: peripheral or bit banging? John Speth <johnspeth@yahoo.com> - 2020-11-20 06:56 -0800
  Re: I2C Single Master: peripheral or bit banging? Michael Kellett <mk@mkesc.co.uk> - 2020-11-21 09:10 +0000
    Re: I2C Single Master: peripheral or bit banging? Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2020-11-21 11:48 +0200
    Re: I2C Single Master: peripheral or bit banging? pozz <pozzugno@gmail.com> - 2020-11-22 17:35 +0100
      Re: I2C Single Master: peripheral or bit banging? Michael Kellett <mk@mkesc.co.uk> - 2020-11-22 20:21 +0000
  Re: I2C Single Master: peripheral or bit banging? Mike Perkins <spam@spam.com> - 2020-11-25 17:43 +0000
    Re: I2C Single Master: peripheral or bit banging? pozz <pozzugno@gmail.com> - 2020-11-26 08:54 +0100
      Re: I2C Single Master: peripheral or bit banging? Mike Perkins <spam@spam.com> - 2020-11-26 14:34 +0000

csiph-web