chipKIT® Development Platform

Inspired by Arduino™

Wire library problem

Created Thu, 29 Dec 2011 07:39:16 +0000 by house91320


house91320

Thu, 29 Dec 2011 07:39:16 +0000

#include "Wire.h" byte inputs=0;

void setup() { Serial.begin(9600); Wire.begin(); // wake up I2C bus

// setup addressing style //Wire.beginTransmission(0x20); //Wire.send(0x12); //Wire.send(0x20); // use table 1.4 addressing //Wire.endTransmission(); }

void loop() { Wire.beginTransmission(0x24); Wire.send(0x13); // set MCP23017 memory pointer (0x12)=A (0x13)=B Wire.endTransmission(); Wire.requestFrom(0x24, 1); // request one byte of data from MCP20317 inputs=Wire.receive(); // store the incoming byte into "inputs" if (inputs>0) // if a button was pressed { // Serial.println("IM GOING TO TRANSMIT A STRING OF DATA FOR YOU BOE OK"); Serial.print("C"); Serial.println(inputs, BIN); // display the contents of the GPIOB register in binary //delay(200); // for debounce } }

This code works on my arduino, but when i brought it to the chipkit it stopped working. Anyone got any ideas?


marcus.walther

Wed, 18 Jan 2012 04:00:12 +0000

I had a similar problem. One important difference in the hardware is that the arduino has the I2C pull up resistors implemented on the processor chip and turned on in the software. On the ChipKit board, the same hardware feature does not exist, and you need to add a pull up resistor to each of the data and clock lines. When I added two 5K resistors to pull these lines high, it worked just fine. Any chance you have the same issue?