Electronics > Projects, Designs, and Technical Stuff

I2C automatic data rate adaption to pullups

<< < (6/6)

Siwastaja:
With I2C devices, a gazillion things can go wrong, and detecting them all, and differentiating between them, bloats it up and doesn't provide proper resistance against unimagined errors left unhandled.

A plain old watchdog which looks at the expected data changes and resets the whole thing at the fullest and lowest level possible (I heavily recommend a PFET on the Vcc line of the I2C device, so you can hard boot it), protects against most errors; the only downside is that when you get an error, it takes time to recover. But with I2C, slowness and uncertainty is inevitable anyway.

Do test such reset procedure thoroughly, by throwing thousands of randomly timed resets during operation at it. MCU I2C implementations may have more hidden state than you'd think. Slave devices can do anything, power cycling is the only reliably way. Some implement nondocumented, nonstandard interface reset patterns which are handy when you know they work. Modern microcontrollers do have peripheral reset registers developed by different part of the team than the peripherals themselves, which issue reset signals to the peripheral blocks. These tend to be the best, after the actual chip reset.

T3sl4co1l:
Although once you've added the power switch, you need as many signals as SPI anyway, so you might as well just.... :P

Not that SPI is any better -- there are a number of devices from big names that have abysmally brain-dead "SPI" implementations that require power cycling just as much. :palm:

Tim

jmaja:
I have never needed to power cycle a SPI device. I have made MCU systems using SPI sensors that have been constantly powered for years. No problems so far.

So I designed to PCB for this project without option to cycle power, even for the MCU. There will be no switches and no possibility to remove the battery. I did add a reed switch, but that will only pull MCU reset low when a magnet is put close enough.

This is just a prototype and I may need to add power cycling for I2C. During software development there have been many issues with I2C hanging the MCU. I haven't quite been able to track what is going on, but most often SCL is stuck low, but I don't always know which chip is pulling it low and the problem has suddenly gone away. Toggling SCL 9 times hasn't helped. With SPI I never had such problems. I hope these are solved when I get the PCB. Now I just testing with demo boards connected with loose wires and sometimes poor contacts. Perhaps a good test environment for unexpected problems?

How do you power cycle I2C without a reset pin etc? How do you deal with SCL and SDA with pullups and possible other sources of GND and  VCC through ESD diodes? The sensors I use draw only 0.2 uA while sleeping. You need to actively put GND and VCC together or wait a long time for capacitors to drain. Time constant is several minutes and you would need to get the chip VCC quite low to be sure it will reset.

The I2C pins have different voltage ratings comapare to other pins (1.8-5 vs. 2.5-3.6). Can they remain at 3 V while VCC is at 0 V? At least I would need to power down all the circuits possibly conducting VCC to all the other pins of the I2C chip.

Long time ago I was stupid enough to cut the power from a SPI chip (SD card) in order to save power without dealing with SPI bus. Of course it was powered through SPI bus.

Navigation

[0] Message Index

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod