Running 2 I2C with AVR128DA48

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Hello!

 

I would like to run 2 I2C devices and it seems that I need to change the pin out for this configuration.

 

 

The normal 1 i2c is PC2 and PC3  according to this

 

which works but what do i need to do to configure 2 i2c channels now. The chip in the first image shows sda0 scl0 and sda1scl1.

 

I tried Wire.swap(pin_set) but i don't think im doing it right. here what I tried

 

Wire.swap(1);

Wire.pins(PIN_PA2, PIN_PA3);

Wire.begin();

 

this doesn't seem to work.

 

Here is the link to the documentation:  https://github.com/SpenceKonde/D...

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It is clearly stated in the data sheet.
The default port for TWI1 is PF2 / PF3.
You don't have to do anything special to use the two. Each exists independently.
You can change the pin position with the PORTMUX register.
I don't know if the library takes that into account.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I2C is natively designed to handle several devices on one bus. Normally, the only time that you run into problems is when you have several devices with the same  bus address. If you can tell us what devices you want to use, someone can help.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

Last Edited: Tue. Jun 21, 2022 - 03:34 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wire.pins(PIN_PC2, PIN_PC3);

Wire.begin();

Wire1.pins(PIN_PF2, PIN_PF3);
Wire1.begin();

 

The first I2C works but the second one doesn't. I can confirm that this worked on my teensy so I know it has to with the setup and not the devices and code.

 

Its also supposed to be master and slave which is what I set it on to the Arduino IDE.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

they are 2 esp32 devices