chipKIT® Development Platform

Inspired by Arduino™

I2C on Max32

Created Tue, 11 Oct 2011 23:08:42 +0000 by scottharris


scottharris

Tue, 11 Oct 2011 23:08:42 +0000

Is supposed to be this working (was hoping the wiki was outdated)? I've got a simple demo using the WIre library and I don't see anything when I scope SDA and SCL.

Thanks, -Scott


scottharris

Sun, 16 Oct 2011 23:29:50 +0000

This code works fine on an Arduino Mega 2560 and a scope on SCL shows activity. The same code on a Max32 with the addition of 4K7 pull-up resistors shows no activity on SCL.

Has anyone gotten I2C working on the Max32? I'm guessing that it should be straightforward to add support based upon the Uno32 code.

Hints, tips, comments? Is anyone working on this? I'll dive into the code and help add support if somebody can let me know the plans and status for I2C on the Max32.

Thanks, -Scott

---code (standard arduino demo plus activity blinker)---

// Wire Master Writer // by Nicholas Zambetti <http://www.zambetti.com>

// Demonstrates use of the Wire library // Writes data to an I2C/TWI slave device // Refer to the "Wire Slave Receiver" example for use with this

// Created 29 March 2006

// This example code is in the public domain.

#include <Wire.h>

void setup() { Wire.begin(); // join i2c bus (address optional for master) pinMode(13, OUTPUT); }

byte x = 0;

void loop() { digitalWrite(13, HIGH); Wire.beginTransmission(4); // transmit to device #4 Wire.send("x is "); // sends five bytes Wire.send(x); // sends one byte
Wire.endTransmission(); // stop transmitting digitalWrite(13, LOW); x++; delay(5); }


scottharris

Mon, 17 Oct 2011 00:04:00 +0000

I'll add that I spent some time looking at the data sheets and Uno32 and Max32 schematics. I can't see why the same code would not work on both devices.

Anyone?

Thanks, -Scott


rosimildo@gmail.com

Tue, 18 Oct 2011 02:02:38 +0000

The address of the slave must be above 8.

Rosimildo


scottharris

Fri, 21 Oct 2011 19:40:13 +0000

Changing the address to 9 seems to fix it; now I see activity on SDA and SCL. I'm surprised the default Arduino example doesn't follow the rules and uses a slave address <8.

Take a look at Examples->Wire->master_writer.

This example is included with Mpide and caused my problems/confusion. It works on Arduino, but not the Max32. Should we change the example code (or convince the arduino folks) to a slave address>8?

Also, I haven't looked yet, but is the >8 requirement enforced in code or hardware on the ChipKIT? Maybe we should try to be compatible with Arduino and not the I2C standard?

Thanks! -Scott

The address of the slave must be above 8. Rosimildo


alexa

Mon, 07 Jan 2013 21:01:55 +0000

This seems to be a limitation of the PIC chip.

http://www.chipkit.org/forum/viewtopic.php?f=7&t=1157