What value has the ACCELEROMETER_ADDR and what is the ADXL345's pin 12 tied to?
What is the value of your uint8 reg?
Which board are you using and which pins are you using for I2C?
Move the first UART_UartPutChar(ackStatus) out of the I2C transaction, this might take a reasonable time.
ACCLEROMETER_ADDR is 0x1D, and I'm using the ADXL345 Breakout module, so there's no pin 12.
This is the only Device that's communicating on I2C with the PSoC so I'm assuming no Alternate addresses are required.
I'm giving uint8 reg 0x00 as I want to verify the datasheet and actual value of the DevID (It's supposed to be 0xE5 but coming out 0x00 because the I2C communication has some problem)
I'm using CY8KIT-042-BLE kit, and for SCL - P0::SDA - P0
I've run This code too-
uint8 Accelerometer_RegRead(uint8 reg, uint8 *value)
uint8 ackStatus1 = COMM_FAIL;
uint8 ackStatus2 = COMM_FAIL;
ackStatus1 = I2C_I2CMasterSendStart(ACCELEROMETER_ADDR, I2C_I2C_WRITE_XFER_MODE);
if(ackStatus1 == I2C_I2C_MSTR_NO_ERROR)
ackStatus1 = I2C_I2CMasterWriteByte(reg);
ackStatus1 = I2C_I2CMasterSendRestart(ACCELEROMETER_ADDR, I2C_I2C_READ_XFER_MODE);
*value = I2C_I2CMasterReadByte(I2C_I2C_NAK_DATA);
ackStatus2 = I2C_I2CMasterSendStop();
After all I2C transactions I'm taking the values on UART but the result is still same.
I've attached the archived project if required
Interfacing.cyprj_.Archive01.zip 608.3 K
Never mind I solved it. The Alternate addresses & the normal addresses of the ADXL345 and got mixed with the alternate and normal Read and Write addresses. I checked it after you pointed it out and exchanged 0x1D with 0x53.
Now I've sorted it out and getting the reading in 16 unsigned bits
Thanks for the help Bob,
Thanks, It's a friend's dog.