chipKIT® Development Platform

Inspired by Arduino™

I2C beginTransmission Lockup with Arduino IDE 1.6.7 and Chipkit Core V1.1.0

Created Sat, 30 Jan 2016 19:51:27 +0000 by shivensys


shivensys

Sat, 30 Jan 2016 19:51:27 +0000

Hi,

I was running I2C communications fine with the Arduino IDE 1.6.4 and the ChipKit plugin on a CMOD like setup, but when I upgraded to Arduino 1.6.7 using Chipkit Core 1.1.0 all I2C communications lock up at the Wire.beginTransmission() call. The port is transmitting the address OK but the final clock pulse goes low and stays low forever. Other code like LCD and digital IO are working fine.

Here is an example of the code:

#include <Wire.h>

void setup() { Wire.begin();
}

void loop() { Wire.beginTransmission(0x50); //never gets beyond this instruction Wire.write(0x00); // MSB Wire.write(0x00); // LSB Wire.endTransmission(); Wire.requestFrom(0x50,1); if (Wire.available()) Wire.receive(); delay(500); }

Any ideas?

Thanks in advance


EmbeddedMan

Sat, 30 Jan 2016 22:18:49 +0000

The I2C library was updated in the more recent chipKIT core releases to more closely mimic the Arduino I2C library.

What chipKIT board are you using, and what I2C peripheral are you talking to?

*Brian


shivensys

Sat, 30 Jan 2016 22:28:42 +0000

The chipkit board is cmod, the peripheral is an I2C eeprom 24LC64 (and others) all I2C devices show the same behavior.


shivensys

Sun, 31 Jan 2016 13:21:57 +0000

As a work around if I replace the files in the Wire library in the folder: "c:\Users\xxxxxxx\AppData\Local\Arduino15\packages\chipKIT\hardware\pic32\1.1.0\libraries" with the one from version 1.0.0 the I2C port works again.

Patrick


EmbeddedMan

Tue, 02 Feb 2016 13:50:28 +0000

Patrick,

I want to thank you for this bug report. The chpiKIT dev team (Keith V in this case) has extensively investigated exactly what's going on with the v1.1.0 I2C code, and found a bug that is causing the problems you are experiencing.

This is the bug record in GitHub, although the technical details of the issue are in an e-mail chain and don't translate into GitHub easily. https://github.com/chipKIT32/chipKIT-core/issues/167#issuecomment-178376536

There is a new test-build of chipKIT-core that has been created with this bug fixed, and you can download manual install versions for each supported platform here : http://chipkitjenkins.wayneandlayne.com/job/chipKIT-core%20PR%20Builder/77/

If you need instructions on how to install these, please see the chipKIT Wiki http://chipkit.net/wiki/index.php?title=ChipKIT_core

We have tested this new build and it appears to fix the problem you found. Again, many thanks-

*Brian


shivensys

Thu, 04 Feb 2016 00:39:48 +0000

Hi Brian,

This fixes it, thanks for the quick response!

Patrick


rebillat

Thu, 17 Mar 2016 11:06:57 +0000

Dear all,

Thanks for all the support you provide. I encounter exactly the same problem as the one reported by Patrick. I’m unable to make I2C work using a ChipKit UNO32 alongside with the MPIDE 0150 under Windows (see minimal code example below). I did the same test with a Arduino UNO and it works perfectly. It is a simple I2C scanner used with a ITG-3200 breakout. It involves only ” Wire.beginTransmission” and ” Wire.endTransmission” functions. It appears that no troubles appear when compiling but that nothing runs after the call of "Wire.beginTransmission".

I tried to download the new Windows version of the core you provided (see link: http://chipkitjenkins.wayneandlayne.com/job/chipKIT-core%20PR%20Builder/77/). To install it, I used the procedure mentioned above but in the MPIDE folder instead of inside the ARDUINO folder. When trying to upload the code to the board I end up with some error messages (see below).

So I would be really grateful if you could provide me any help as I have a bunch of those cards for my students and I really would like to make them work with I2C.

With my best regards.

Marc

// BEGIN MPIDE ERROR MESSAGE

pic32-g++.exe: error: chipKIT-application-COMMON.ld\cpp-startup.S: No such file or directory C:\Program Files (x86)\mpide-0150/hardware/pic32/compiler/pic32-tools/bin/pic32-g++::-Os::-Wl,--gc-sections::-mdebugger::-mno-peripheral-libs::-nostartfiles::-mprocessor=32MX320F128H::-o::C:\Users\rebillat\AppData\Local\Temp\build7358692860307108603.tmp\sketch_mar17a.cpp.elf::chipKIT-application-COMMON.ld\cpp-startup.S::C:\Users\rebillat\AppData\Local\Temp\build7358692860307108603.tmp\sketch_mar17a.cpp.o::C:\Users\rebillat\AppData\Local\Temp\build7358692860307108603.tmp\Wire\Wire.cpp.o::::C:\Users\rebillat\AppData\Local\Temp\build7358692860307108603.tmp\core.a::C:\Users\rebillat\AppData\Local\Temp\build7358692860307108603.tmp::-LC:\Program Files (x86)\mpide-0150\hardware\pic32\cores\pic32::-lm::-T::chipKIT-application-32MX320F128.ld/C:\Program Files (x86)\mpide-0150\hardware\pic32\cores\pic32::-TchipKIT-application-COMMON.ld/{14} returned 255

// END MPIDE ERROR MESSAGE

// BEGIN SAMPLE CODE #include

char id=0;

void setup() { Serial.begin(9600); while (!Serial); Wire.begin(); }

void loop() { byte error; byte address; int nDevices;

Serial.println(“\n[I2C Scanner]”); Serial.println(“Scanning…”);

nDevices = 0; for(address = 1; address < 127; address++ ) { Wire.beginTransmission(address); error = Wire.endTransmission(); if (error == 0) { Serial.print("I2C device found at address 0x"); if (address<16) Serial.print("0"); Serial.print(address,HEX); Serial.println(" !"); nDevices++; } } if (nDevices == 0) {Serial.println("No I2C devices found\n");} else {Serial.println("Done\n");} delay(5000) ; } // END CODE


rebillat

Thu, 17 Mar 2016 12:16:49 +0000

Hi again,

By the way, I checked if it changed something when using the ARDUINO IDE with the new CHIP KIT core instead of the MPIDE. Surprisingly, I don't have any more errors when compiling the code and sending it to the board. However, at the end it doesn't work as Wire.endTransmission() returns me "2" which means "received NACK on transmit of address" for each adresses (even the one where there is sompething plugged...). Again I emphasize the fact that it runs correctly on an ARDUINO UNO with the same wiring, so the problem should come from somewhere else.

Thanks in advance for any help.

Marc


ltheoret

Sun, 20 Mar 2016 04:14:24 +0000

Hi,

Curious, the Arduino DUO has a similar problem. Here is the link:

[url]https://forum.arduino.cc/index.php?topic=386269.0[/url]

Luc