Code:
I2Cread ADXL345_SDA,ADXL345_SCL, $A7, $00, [X0] ' Read Device ID
serout2 RS232_TX, 6, ["ID: ",bin8 X0,13,10] ' The result should be 11100101 but is 00010000 like all other read results.
I2CWRITE ADXL345_SDA,ADXL345_SCL, $A6, $2D, [8] ' Put into Run Mode
pauseus 5
Main_I2C:
I2Cread ADXL345_SDA,ADXL345_SCL, $A7, $32, [X0,X1,Y0,Y1,Z0,Z1] ' Read accelerometer data
serout2 RS232_TX, 6, ["X: ",dec X0,",",dec X1]
serout2 RS232_TX, 6, [" Y: ",dec Y0,",",dec Y1]
serout2 RS232_TX, 6, [" Z: ",dec Z0,",",dec Z1,13,10]
pause 100
Goto Main_I2C
When reading back any byte the answer is always 16 or 00010000, which implies that I have something fundamentally configured wrong.
Bookmarks