
PCF8574A coding reality check
I'm trying to help someone with the following bit of code.
It needs to set pin 0 to high, the low and set pins 1 to 7 to high for input.
Then read pins 0 through 7
 |  |  |
 | Code: typedef struct{ byte i2cMessageSize; byte i2cDeviceAddress; byte i2cWriteMessage; } i2c_mess;
task main() { unsigned byte value[1]; int cnt=0; //****** just a counter, not needed
SensorType[S1] = sensorI2CCustomFast;
i2c_mess ledArray; ledArray.i2cMessageSize = 1; ledArray.i2cDeviceAddress = 0x70; ledArray.i2cWriteMessage = 0xFF;
while(1) { cnt++; //****** just a counter, not needed
nI2CBytesReady[S1] = 0;
ledArray.i2cWriteMessage = 0xFF; if (nI2CStatus[S1] == NO_ERR) sendI2CMsg(S1,ledArray.i2cMessageSize,1);
wait1Msec(50);
ledArray.i2cWriteMessage = 0xFE; if (nI2CStatus[S1] == NO_ERR) sendI2CMsg(S1,ledArray.i2cMessageSize,1);
wait1Msec(50);
while (nI2CStatus[S1] == STAT_COMM_PENDING) wait1Msec(2);
if (nI2CStatus[S1] == NO_ERR) readI2CReply(S1, value[0], 1);
nxtDisplayTextLine(2, "value %d", (int) value[0]); nxtDisplayTextLine(3, "cnt %d", cnt); } }
|  |
 |  |  |
this is working perfectly for me, but not my friend.
Im seeing a nice 0 to 5v square wave on pin 0 and pins a through 7 are working as inputs.
Is there something Im missing?