After much scratching of the head I connected the logic analyser and figured out what is happening but not what is wrong with this code.....
for (byte a=0x10; a<0x12; a++)
{
byte d = 0x01;
I2C_WRITE_BYTE(a, d); // 1 register 0x10
// delay(300);
d<<1;
I2C_WRITE_BYTE(a, d); // 2
// delay(300);
d<<1;
I2C_WRITE_BYTE(a, d); // 4
// delay(300);
d<<1;
I2C_WRITE_BYTE(a, d); // 8
// delay(300);
d<<1;
I2C_WRITE_BYTE(a, d); // 16
// delay(300);
d<<1;
I2C_WRITE_BYTE(a, d); // 32
// delay(300);
d<<1;
I2C_WRITE_BYTE(a, d); // 64
// delay(300);
d<<1;
I2C_WRITE_BYTE(a, d); // 128
// delay(300);
d = 0x00;
I2C_WRITE_BYTE(a, d); // 00
// delay(300);
}
I think it's fairly obvious this code is supposed to write value d to address a, shift d one bit to the left and write the new value to a
However if I take monitor the i2c bus on my logic analyser it continually writes the initial vlaue of d (does not bit shift)
It looks OK to me and the C reference manual says the syntax d<<1; is correct so what is wrong?
(I had to comment out the delays to give my anayser a better chance to capture the data)
Rich