LIS2DH12TR accelerometer sensor
Hi ,
I'm trying to read the accelerometer data from the LIS2DH12TR which is connected to CC1310 TI's Controller.
In my design I'm using I2C hence i have connected the CS pin to Vdd(3.3V) and SA0 pin to VDD. As per the Data sheet with my case the address will be 0x19(SA0 is connected to Vdd).
I'm able to initialize the I2C and while reading the Data it always prints all values to zero except the Out_Z(H & L) and Out_H and Out_L are 255(Out_Z= accelerometer values in the z direction).
What could be the reason for this?
I assume it's factory calibrated.
Here's the attached code with CC1310(CCS):
txBuffer[0] = 0x0C;
i2cTransaction.slaveAddress = 0x19;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount =1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 2;
status = I2C_transfer(i2c, &i2cTransaction);
while (status == false) {
// Unsuccessful I2C transfer
Display_printf(display, 0, 0, "Unsucessful I2C Read");
sleep(2);
}
txBuffer[0] = 0x28;
i2cTransaction.slaveAddress = 0x19;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount =1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 6;
status = I2C_transfer(i2c, &i2cTransaction);
while (status == false) {
// Unsuccessful I2C transfer
Display_printf(display, 0, 0, "Unsucessful I2C Read");
sleep(2);
}
/* Take 20 samples and print them out onto the console */
for (sample = 0; sample < 1231150; sample++) {
if (I2C_transfer(i2c, &i2cTransaction)) {
/* Extract degrees C from the received data; see TMP116 datasheet */
//temperature = (rxBuffer[0] << 8) | (rxBuffer[1]);
//temperature *= 0.0078125;
TMP = (rxBuffer[0] <<8) | (rxBuffer[1]);
AcX = (rxBuffer[1] <<8) | (rxBuffer[2]);
AcY = (rxBuffer[3] <<8) | (rxBuffer[4]);
AcZ = (rxBuffer[5] <<8) | (rxBuffer[6]);
