Hello friends, I'm new to microcontroller programming and I came across a situation.
Micro in 3.3v, 18LF26K22 and I could not understand if it supports in SDA and SCL 5V. It will be connected to the ds1307 at 5v.
I couldn't understand whether I need YES or NO.
Some say it is necessary to use a logic level converter, others say that it is enough to connect the pull-up resistor to 3.3v.
After all, can I use only the pull-up or do I need to assemble a logic level converter circuit ??
You need to use a logic level converter I'm afraid. That device has a maximum VDD of 3.6V and none of its pins are 5V tolerant.
A BSS123 is a good alternative to the 2N7000 but any 'logic level' small MOSFET will work. You need one for the SCL and one for the SDA lines.
You can add other 5V i2C devices from the same converter.
You need to use a logic level converter I'm afraid. That device has a maximum VDD of 3.6V and none of its pins are 5V tolerant.
A BSS123 is a good alternative to the 2N7000 but any 'logic level' small MOSFET will work. You need one for the SCL and one for the SDA lines.
You can add other 5V i2C devices from the same converter.
I might be wrong here but SDA and SCL both open drain, PIC and RTC, and min logic 1 for DS1307 is 2.2V,
so if buss pullups are to PIC Vcc then everybody is happy. If the pullups dont turn on parasitic diode in
PIC, or if they do but injection current limited all is fine. But latter not issue since Pullups fed by PIC Vcc.
Is it safe to connect any 5V I2C slave device to 3.3V host? I know, that DS1307 realtime clock can be connected to Raspberry Pi (3.3V IO), because DS1307 just pulls down data lines and 5V voltage ...
And in the company, I have 1000 or more DS1307, which are from projects that the engineer used in the past, so I will continue to use them. The PIC18LF26K22 also has several units.
Thanks to everyone for your help, I understand that the DS1307 can work at 3.3 on the clock and data line. So I can just connect the pull-ups to 3.3v or use the logic level converter. Either option will work.
If the DS1307 also runs on 3.3V there is no problem but the PIC pins are not open drain. To control I2C lines they are driven low and the TRIS (like tri-state) is used to isolate the pin when it is to be externally pulled high. If the pull-up is to 5V it will exceed the PIC input voltage rating and will probably forward bias it's pin protection diode and clamp the voltage a little higher than VDD. It isn't a good solution but it will probably work. Some of the newer PICs have 5V tolerant pins but sadly not that one.
Yes, SDA and SCL are open drain, but also clamped to Vdd by protection diodes. Respectively I2C pull-ups should connect to Vdd (3.3 V). As already stated, 5V supplied DS1307 can work with 3.3V I2C levels.