0

I'm doing a circuit with an ATINY85 IC and an I2C sensor, and it'll be programmed by SPI. The SDA and SCL lines of the Attiny85 are the same as the MOSI and SCK pins needed for programming.

I've read a few posts on how to isolate the SDA and SLC lines when proogramming the Attiny85 (like this one: Isolate I2C sensor from Master while programming). Solution of the post below:

enter image description here

Would this option below be effective also? I though about the same idea of the previous post, but I disconnected the I2C sensor supply line (it runs at 5V), and left the SDA and SCL lines connected. The SDA and SCL are pulled high on the sensor, but there'll be not supply for these pins while programming.

EDIT: The SDA and SCL lines are also pulled high by a 10k resistor in my pcb also, so they would be pulled high all the time, even with the sensor VIN disconnected. Would it also affect programming the MCU by SPI?

Alternative setup

When one Attiny GPIO is set to high, the sensor would be turned on. When programming, the GPIO is pulled low, and the sensor is disconnected.

Would this work also as a method to program the Attiny by ISP without conflicting with the I2C sensor (in my case a TOF sensor, VL6180X). Should I modify something? Or I must use the other post's solution?

Rodrigo
  • 467
  • 2
  • 8
  • Maybe this helps (based on AVR042: AVR Hardware Design Considerations). See the chapter headed "Shared use of SPI programming lines" : https://onlinedocs.microchip.com/pr/GUID-F626284A-58F0-4C25-A6F3-0EA5054F3E2B-en-US-6/index.html?GUID-487B3F5E-C5E0-4DB1-9E75-CBE2E524AD06 In principle, separate the SPI programming lines from anything else which may also use these by 330 ohm resistors. – 6v6gt Dec 09 '22 at 20:36
  • @6v6gt, thanks, I read it. But it's not specific about the I2c devices. Only adding 330R in series to the SPI lines would solve it? That simple? Would there be no conflicts? – Rodrigo Dec 10 '22 at 13:37
  • Yes. Providing that anything else that is sharing the SPI lines is at least 330 ohms "away" from the programmer, there should be no interference with the programming of the MCU. However, you also have to consider the connected (I2C) devices may only be 3.3 volt tolerant. But in that case you should anyway have level shifters as you have illustrated (first schematic). If, however, you'll normally run the ATtiny85 at 3.3 volts and only use 5 volts for programming, it would be best to use jumpers on header pins to isolate the external devices. – 6v6gt Dec 10 '22 at 16:50
  • @6v6gt, I´ll be running everything at 5V. The I2c device (VL6180X) has an LDO and level shifters that accept 5V at the SDA and SCL lines. So I won´t need extra level shifters in my case... Maybe increase the resistors to 500ohms to accept 5V? – Rodrigo Dec 10 '22 at 21:55

0 Answers0