News:

;) This forum is the property of Proton software developers

Main Menu

2 I2c

Started by tolyan249, Oct 07, 2026, 05:52 PM

Previous topic - Next topic

tolyan249

Question: how can I create 2 I2C ports?
Since the speeds are very different, one hardware port works with an OLED display, and I need a second software port for the equipment. For the second port, I want to use the I2C_software.inc file for PIC12F1840.

Thank you.

Frizie

You can opt for the software variant using the I2CIn and I2COut instructions.
Ohm sweet Ohm | www.picbasic.nl

trastikata

You can still use the same hardware I2C port, just change the speed before accessing the devices. Use the SSP1ADD to set the new speed, you can calculate it as shown on page 259, equation 25-1.

tolyan249

Thanks everyone.

tolyan249

One more question. If the controller is powered by 5V and the OLED display is also powered by 5V, do we need to match the SCL and SDA levels? Or will it work like this?
Since the display has a 3.3V stabilizer.

trastikata

#5
Check the datasheet for the required voltage levels on those I2C pins - if 3.3v is sufficient, then just connect the pull-up resistors to the 3.3v rail.

Edit:

I checked it for you:
- the I2C logic requires 0.7xVDD as minimum for high - 3.3v is border line - hardware I2C might work or might not.
- The general IO port uses TTL, so for the same pins the minimum high is 0.25xVDD + 0.8v which means software I2C will work with 3.3v pull-up resistors.

JonW

#6
If voltage domains are within 0.4V over temp you are safe.

I2c always needs pull ups. If you counter a voltage domain conflict greater than 0.5V, shift the levels.

Imho
Domain is usually bounded by a diode. Generally esd frame diodes in the Ic.  Hence is speed is not a major issue add current limiters to about 20maA

▲