chipKIT® Development Platform

Inspired by Arduino™

Trouble with built-in Wire/I2C Master<>Slave Demos [Max32]

Created Wed, 14 Nov 2012 05:07:10 +0000 by snovich


snovich

Wed, 14 Nov 2012 05:07:10 +0000

Hi all,

I'm trying to run the I2C/Wire Master-Write/Slave-Reader pair of demos in Mpide. I'm trying to get my Max32 to act as a master and communicate with an Arduino Uno, but am having no luck:

More details: (1) I tested using an Arduino Mega (in place of the Max32) as a master talking to an Uno, and had no issues communicating (2) I made sure to share ground + 5V between the boards (3) I made sure to add pull-up resistors (tried various resistances between 1K>10K) to the SDA/SCL lines

I wish I had a DAQ, but unfortunately I don't, so not exactly sure how to go about troubleshooting this. It may be that the library just isn't supported yet? The wiki DOES say that I2C/Wire hasn't been implemented for the Max32, but that's on an earlier version of Mpide - so I'm not sure if that's out-of-date.

Any help would be appreciated, thanks!


jRobert

Wed, 14 Nov 2012 06:06:01 +0000

Try changing the device ID to anything other than numbers in the examples. That's how I got UNO32 to talk to Arduino UNO. You don't need pull-up resistors. The Arduino has internal pull-ups enabled by the Wire library.


snovich

Wed, 14 Nov 2012 06:17:57 +0000

Cheers - I'll give that a shot. On that note (and maybe I should start a different topic on this): I'm running into a similar issue with SPI for Max32>Uno communication, where the Mega>Uno works, but Max32>Uno does not (and made sure to set the jumpers accordingly). Have you had any luck doing anything along these lines?

Thanks again.


les1943

Wed, 14 Nov 2012 19:29:06 +0000

May be relevant ? I am working with a UNO32 and a PIC16F886 as an I2C slave (a I2C to serial printer interface written in asm ) I have noted that the device address(7 bit) in UNO must be shifted left one by 'wire' and the R/W bit added as an address say 0x22 in UNO is received and recognized as 0x44 in PIC...


snovich

Wed, 14 Nov 2012 20:57:27 +0000

May be relevant ? I am working with a UNO32 and a PIC16F886 as an I2C slave (a I2C to serial printer interface written in asm ) I have noted that the device address(7 bit) in UNO must be shifted left one by 'wire' and the R/W bit added as an address say 0x22 in UNO is received and recognized as 0x44 in PIC...

Interesting. Can you elaborate how you determined this a bit more? I'd be interested in performing a similar debugging here.

For the record, I just tried jRobert's idea of changing the default I2C demo address from 4 to 10 (randomly chosen) on both sides of the demo, and everything magically started work. So it doesn't appear that a shift would be necessary. And @ jRobert (or anyone else) - any ideas as to why the default address of 4 doesn't work? I'm looking at the PIC32 I2C reference manual, and can't gleen anything from it that would suggest why...


les1943

Wed, 14 Nov 2012 21:28:15 +0000

I programmed the PIC to monitor the bytes received in the MSSBUF register (via ISR) and display the HEX via a serial LCD.. I set UNO to r/w slave device 0x22 , in the PIC I2C addr was 0x44 ,(SSPADD) only then did byes start appearing in the MSSBUF (in out register)... from decoding the SSPSTAT, read / write / start /stop ect i was able to RX TX with uno sucessfully. The PIC will only set the interrupt for an address match, it then puts address it in MSSBUF so it can be monitored , but usually discarded as the next byte is the data sent.

I have wire.send and wire.requestfrom working OK

Note.. Uno seems to send strange I2C frames. but i just ignored them. !

Hope that makes sense..