What pins to use for I2C bus with AVR Mega2560

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:

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.

[quote author=Nick Gammon link=topic=105823.msg794692#msg794692 date=1337065817]

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. [/quote] 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.

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

Thank you for your polite response. :)

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.

I'm just trying to do this now, using a Mega2560+RAMPS that has a 4-pin I2C connector on one end as master and a second bare Mega 2560 as slave. I have 3 pins connected. SDA to SDA, SCL to SCL, and GND to one of the GND pins on the slave. I've set up a sketch on each one. From the master I'm using the serial console to send bytes over I2C to the slave. The slave is supposed to echo the bytes received. If a request is sent to the slave, it's supposed to reply with "Hello world!\n".

So far, no go.

Are the 4 pins on a RAMPS just passthroughs for pins 20/21 or could they be other pins? Do I need to connect the 5V pin between the two Arduinos? (They're both being USB-powered at the moment.)

The SCL and SDA pins are being correctly defined in fastio.h for the board(s).

I've used Wire.begin(2) on the slave, and Wire.begin() on the master.

Does the slave needs to be interrupted in order to call these handlers, or does Wire library just poll the pins? If the former, is it possible that other interrupt settings could interfere with the i2c bus?

Much to learn about this topic!

21pin is the SCL and 20 pin is the SDA I tested!!! :o :o :)