AnsweredAssumed Answered

LIS3DSH I2C understanding

Question asked by barnsley.cinnibar on Apr 10, 2016
Latest reply on Apr 11, 2016 by FTITI.Walid
Hello Community,

I am currently trying to get my head around the LIS3DSH accelerometer using the I2C HAL library, however I am having a great deal off difficulty in achieving anything.

My aim is to simply read the axes which seems straight forward using SPI, but when I attempt to do the same in I2C I am having no luck.

I am currently using the lines

device_Address = 0x1D;
reg_Address = 0x20;
i2c_Data = 0x67;
HAL_I2C_Mem_Write(&hi2c1, device_Address, reg_Address, 1, &i2c_Data, 1, 200);


to write to CTRL_REG4.

And then 

reg_Address = 0x28;
HAL_I2C_Mem_Read(&hi2c1, device_Address, reg_Address, 1, &i2c_Data, 1, 200);
 

in attempt to read from the OUT_X_L register, however the code is not yielding anything due to a lack of understanding on my behalf.

Can anyone point me in the right direction to get readings from the registers using the I2C HAL library, or some useful information on using I2C?

Thanks (Also my apologies for the appalling formatting, I am new to the forum and hope to learn a better method)

Outcomes