6

I just asked this question trying to find out if having a powered I2C slave in an ISP bus during MCU (Attiny) programming would be problematic. Apparently it would, so I need to isolate the slave(s) from the bus temporarily.

I can't just power down the slave(MPU-6050) because its inputs are not tolerant to 3.3V when its Vcc=0V.

I also found this interesting related question, but the solutions proposed do not work for me (I have limited board space and specific ICs availability are a problem for me for this projects budget).

I'm really trying to steer away from a jumper/DIP switch solution so I'm considering active ones. Here it goes:

Use a discrete bi-directional level shifter

enter image description here

But instead of a High and Low voltage side, I'd try something like this:

schematic

simulate this circuit – Schematic created using CircuitLab

When Attiny is programming, its outputs are high-impedance, R5 turns M3 off. C1 is mainly to prevent glitches on the pin from turning M3 back on again.

R7 then turns M1 and M2 off, and SCK/MOSI can "bounce" freely without disturbing the I2C slave(s).

Upon booting, the Attiny turns M3 on, providing power to the I2C bus.

Would this work? Am I overlooking or overcomplicating something?

Wesley Lee
  • 7,844
  • 6
  • 35
  • 53
  • I think you are saying that your attiny has a VCC of 0V, sometimes (powered off?) What happens when it is powered off and you have 3.3V to R5 to R6 to your off-mode attiny's gpio pin? Won't that flow through the protection diode to the VCC=0 rail? Is it low enough to be okay? (Doesn't sound like a lot.) But you may have close to 1V on your pfet gate, too. – jonk Sep 16 '16 at 21:09
  • The Attiny is always powered in these scenarios. I just need to prevent any voltage above 0.5V on the I2C bus when the Tiny is being programmed. The slave can be powered off or not if I isolate the I2C bus. I'm sorry, I'll rephrase the question. – Wesley Lee Sep 16 '16 at 21:12
  • Sorry about my misunderstanding. – jonk Sep 16 '16 at 21:13
  • @Wesley Is this for a prototype, or production? Is cost a significant factor? Same question for PCB real estate? – Nick Alexeev Sep 16 '16 at 21:55
  • @NickAlexeev -- I'm making 5~10 units.. PCB real estate is a factor, cost is not much of a factor except for the fact that I live in Brazil and if I need any specific IC I have to pay courier + import taxes, so a 2USD IC from Mouser ~= 100USD cost for me (in this case I'd just use jumpers). That's why I'm preferring a discrete solution. Also using this situation to design and learn something maybe. – Wesley Lee Sep 16 '16 at 22:05
  • What about a 4066 or 4016 or similar (perhaps smaller) analog switch chip? One of those + a pull up or down resistor could do the job nicely, and maybe the generic 4066/4016 chips would be easier to find locally. – alex.forencich Sep 16 '16 at 22:32
  • Would adding a strong pulldown to the two BSS138's? The pull ups are 10k so you could pull them straight to ground via a jumper. – HilarieAK Sep 17 '16 at 00:42
  • @alex.forencich -- that's a nice and easy option, I had forgotten that once I built an I2C switch using 4052. It worked, so your idea is viable. I think I'll try the discrete option with Bruce Abbotts suggestions though. – Wesley Lee Sep 17 '16 at 23:45
  • @HilarieAK -- thanks for the suggestion, but if I where to add jumpers to control the storng pulldowns you suggested then it would be easier to just add jumpers on the I2C bus itself. – Wesley Lee Sep 17 '16 at 23:46

1 Answers1

4

You have the right idea, but I think your circuit can be simplified.

In the idle condition both SCL and SDA should be high, so connect R1 and R2 directly to +3.3V. M1 and M2 have body diodes that must not be allowed to transfer logic low from the ATTiny to the MPU-6050, so you need to swap their Source and Drain connections.

The Gates of M1 and M2 can be driven directly from a GPIO pin, then M3 and R7 are not required. C1 and R5 now connect to Ground instead of +3.3V, and the GPIO pin pulls high to enable the I2C connection.

An I2C 'Start' condition is defined as SDA going from high to low while SCL is high. A slave device shouldn't drive SCL unless it is busy and wants to slow down the data transfer, so SCL should be safe from interference unless the MPU-6050 sees a Start condition while it is busy doing something else. With SDA held high (by R2 with M2 switched off) the MPU-6050 won't see a Start condition so it should leave SCL alone, and M1 and R3 are not required.

schematic

simulate this circuit – Schematic created using CircuitLab

Bruce Abbott
  • 55,540
  • 1
  • 47
  • 89
  • Nice, I didn't realize I didn't need M3. I think that for an extra NFET+Resistor though I'll add isolation on the SCL bus too. R1~R4 will probably be an array, so the extra resistor doesn't affect anything and putting M1 back should also give me a prototype for a discrete I2C switch/"mux" so I'll try that. Good point about the body diodes and I2C idle condition. For some reason I thought it would be low after turning the devices off -- but again, you made me realize I don't even need to turn them off, just make them idle. – Wesley Lee Sep 17 '16 at 23:52