I2C 23008 failing to respond after some time

Hi,

I am using Arduino 1.0.3, a Dorkbot Dorkboard minimal clone and a MCP23008 I2C expander port.

After some time, the I/O port stops updating while the rest of the program keeps running. I’ve reduced the program to a port test program - sending a counter to I/O port driving LEDS.

Minimal code is

/*

Why does Wire functions stop working on the pump control design?

Experiments to work it out.

*/

#include <Wire.h>

const byte ADR23008 = 0x21;
const byte IOR = 0x00;
const byte GPIO = 0x09;

unsigned long reftime;
unsigned long nowtime;
unsigned long epoch = 1000; //1 second

byte LEDS;

void setup() {
Wire.begin();
Wire.beginTransmission(ADR23008);
Wire.write(IOR);
Wire.write(0x00); //set all outputs on i2c MCP23008
Wire.endTransmission();

LEDS = 0x00;
reftime = millis();
}

void loop () {
nowtime = millis();
if (nowtime - reftime >= epoch) {
reftime = reftime + epoch;
PumpControl();
}
}

void PumpControl() {
Wire.beginTransmission(ADR23008);
Wire.write(GPIO);
Wire.write(~LEDS);
Wire.endTransmission(0);
LEDS++;
}

At some time the I/O port just stops responding.

Anybody had a similar issue?

Best REgards

Barry