2017-12-06 12:18 AM
2017-12-06 04:09 AM
HAL wants the I2C address shifted one bit to the left. Instead of ADXL_ADD_RD, try
(uint16_t)ADXL_ADD_RD << 1
The ADXL also wants the chip select pulled high in order to choose i2c. I did not examine that part of your code, I just noticed it in the data sheet.
2017-12-06 11:14 PM
Thanks you suggestion was to the point but the working code is like this if other users struggle the the same problem I have, they should try like this:
HAL_I2C_Master_Transmit(&hi2c1, ADXL_ADD << 1, TX_DATA, 1, 200);
HAL_I2C_Master_Receive(&hi2c1, (ADXL_ADD | 0x01) << 1, RX_BUFFER, 1, 200);I don't know why but using read and write addresses seperately doesn't work. This way however, it works.