TWI on Mega not working (?)

Hi. I’m trying to get TWI working between a Mega (master) and a 328/Duemilanove (slave). I get no response from the slave. I even tried using the examples in the Wire library as-is, and get nothing. I know communication is good from the PC to each board, because I put in Serial.println(“Starting”) signals in both, and they do display.

I happen to also have a second Duemilanove (can’t have too many of these guys…), and when I used that as the master, it worked fine.
I know I’m compiling correctly with the Mega (selecting that as the target board), and using the right COM port (as I said, the serial prints show up).

For connections, I have Mega pin20 <-> Due’s A4, and mega’s 21 <-> Due’s A5 as the documentation says. I also connected the grounds. I noticed on one blog, they also connected the +5V’s, but that made no difference (and seemed odd).

Do I need to include resistors when using the mega? I didn’t use any when successfully connecting the two Due’s, so didn’t think I needed them with the Mega either.

I’d post my code, but like I said, the verbatim Wire library examples are what I used, successfully for two Due’s, but not for Mega/Due.

Any ideas? I know “nothing happens” is a reeeeeally lousy problem description, but any ideas would be welcome. Thanks.

Can you try adding the resistors? IIRC, they're technically required; maybe the ATmega168 / 328 on the Duemilanove is more forgiving than the 1280 on the Mega?

Hi, David. Thanks for taking the time. Nope, the resistors didn't help. As per Atmel docs, I put 10K pullups on SDA and SCL. I think my next step will be to put my Parallax scope on it (still getting to know that thing) and try to see who's sending what. I'd really like to make this work. The Mega solves sooo many problems I was needing to solve in a robot design.

Thanks again, Steve

I’m almost positive I tried a DS1307 (I2C clock) on the mega. No software changes, the only hardware change was the pin remapping you did.


I believe I tried I2C with a BlinkM and the Mega and it worked (i.e. hurt my eyes) - so it should be able to talk to another microcontroller.

Okay. Thanks for giving it some thought. It's GOTTA be something I'm doing (or not...). That's a good idea - I'll try hooking up an I2C chip of some kind.

Thanks, Steve