What pins to use for I2C bus with AVR Mega2560

Documentation seems to say that I2C bus uses pins 20 and 21. In Mega. However in the schemati I2C bus seems to be on pins 43 and 44. What are the correct pins to use.

Pins on the chip and pins on the board are not the same thing. The I2C pins on the board are 20 and 21.

Thank you for your answer but I dont understand it. In Mega shema there are numbers just beside the chip on every pin. They look like pin numbers. To the right of that is pin name, isn't it? For example 44 SDA. What is the reason this.

Can pins 44 and 43 be used as a I2C bus?

In the text for Mega "http://arduino.cc/en/Main/ArduinoBoardMega2560" is written "TWI: 20 (SDA) and 21 (SCL). Support TWI communication using the Wire library. Note that these pins are not in the same location as the TWI pins on the Duemilanove or Diecimila. ".

Leif

This is a case of knowing enough to be dangerous 8)

The 44 & 43 are the physical pins of the ATMega chip itself.

Following the leads to the right, they end at header connector, where they are marked D20 & D21.

There is software mapping that goes on in the IDE (in the pins_arduino.h file) so when you toggle Port D pin 1 & 0, the result shows up at header pins D20 & 21.

you're making it harder than it is. it's labelled right there on the board.

As others have pointed out, 44 and 43 on the processor chip itself, 20 and 21 on the board sockets:

It's all in the schematic:

1 Like

I understand, thank you all.

We are not using Arduino connectors, so those connector pin numbers are not needed here. I did not even look. I must say that the text is now vague, misleading or even dangerous. Now I have to check what pin numbers I have used, CPU or connector. Keeping Arduino simple or trying to do that, is good, but sometimes things are made almost too simple.

Best Regards
Leif M

LMI_at_work:
We are not using Arduino connectors, so those connector pin numbers are not needed here. I did not even look. I must say that the text is now vague, misleading or even dangerous.

It's misleading to post on the Arduino forum a question about using I2C for something which is not an Arduino. Dangerous, even.

CrossRoads:
This is a case of knowing enough to be dangerous 8)

I think OP (original poster) should have just admitted a clear mistake and moved on, but instead tried to find some things to blame.
the fact that the question was even asked tells us the level of knowledge the OP has, and people here are helpful and responded instead f ignoring the question.

Now my english is lacking, so I cant give you a good answer. Your post is polite and good, perhaps light even, so should my answer be.

What makes a board an Arduino board? We are not buying an Arduino board, but building our own. Because we put other (our design) components on the board, we dont need the same connectors. I plan to burn the Arduino bootloader in the beginning to get an easy start. So the board will be very close to an Arduino board.

I quess it is hard to make web site for everyone, but sometimes you should say things just like they are. Nick Gammon's answer made things absolutely clear to me. It is hard to make explanations suitable for everyone, but when there is a forum with answers like that everything is fine.

1 Like

LMI_at_work:
Nick Gammon's answer made things absolutely clear to me.

Thank you for your polite response. :slight_smile:

Hi all

One question.....

I have an arduino mega 2560 board, but not as connect my board to a circuit DS013 (Real Time clock),

What are the pin I2C????? 20 y 21 or near the USB purto????, as shown in figures::

dddd.png

Both. Use whichever is most convenient.

Hablas espanol ?

Is there a possibility to use the pins 20 and 21 as interrupt pins and use SCL and SDA pins near the USB port for I2C simultaneously ?

Is there a possibility to use the pins 20 and 21 as interrupt pins and use SCL and SDA pins near the USB port for I2C simultaneously ?

Check with a multi-meter. I'm pretty sure that you'll find that the SCL and SDA pins and pins 20 and 21 are connected. The extra locations are for convenience, not for isolation.

PaulS:
Check with a multi-meter. I'm pretty sure that you'll find that the SCL and SDA pins and pins 20 and 21 are connected. The extra locations are for convenience, not for isolation.

On the schematic, it shows them connected.

No.

These are the same connections on the controller (the chip).
They have been brought to the different pins for convenience and compatibility.
You can not use them for different purposes.

[edit]
Oops, missed the other answers to the same question.
[/edit]

Emm, yo community, is the assumption that both pins 20 and 21, as well as SCL and SDA pins near the USB terminal are the same and operate in the same manner, and effectively can be used for the same purposes ?

is the assumption that both pins 20 and 21, as well as SCL and SDA pins near the USB terminal are the same

You don't need to assume anything. You can look at the schematics for the board, or take a magnifying glass and follow the traces on the board. See that pins 20 and 21 and the SCL and SDA pins are connected by traces.

and operate in the same manner

That copper trace between them assures that that will be the case.

and effectively can be used for the same purposes ?

That copper trace between them assures that that will be the case.