Hello,
ive encounter a strange problem, when i try read data from lis3dh that are Y_L X_L Z_L they seem all right. buffer[0] buffer[2] buffer[4]
but when it comes to X_H Y_H Z_H data they are only multiplies of 64. buffer[1] buffer[3] buffer[5]
void read_from_sensor_multiple(uint8_t adres, twim_config_t *twim)
{
uint8_t adres_multiple = adres | 0x80;
uint8_t write_buff[1] = {adres_multiple};
uint8_t buffer[6];
nrfx_twim_xfer_desc_t twim_xfer_desc = NRFX_TWIM_XFER_DESC_TXRX(LIS3DH_DEFAULT_ADDRESS, // BME280 I2C
write_buff, // Buffer z adresem rejestru TX
6, // Amount
buffer, // RX buffer
6 // Amount
);
nrfx_twim_xfer(&twim->instance, &twim_xfer_desc, NRFX_TWIM_FLAG_REPEATED_XFER | NRFX_TWIM_FLAG_TX_POSTINC);
x = buffer[0];
x |= ((uint16_t)buffer[1]) << 8;
y = buffer[2];
y |= ((uint16_t)buffer[3]) << 8;
z = buffer[4];
z |= ((uint16_t)buffer[5]) << 8;
uint8_t lsb_value = 4;
float x_g = lsb_value * ((float)x / LIS3DH_LSB16_TO_KILO_LSB10);
float y_g = lsb_value * ((float)y / LIS3DH_LSB16_TO_KILO_LSB10);
float z_g = lsb_value * ((float)z / LIS3DH_LSB16_TO_KILO_LSB10);
LOG_INF("X: %d Y: %d Z: %d\n", buffer[1],buffer[3], buffer[5]);
}that's my function. Should my data output act like this? If not what's wrong with this. Assuming i get right data from 0 2 4 buff places, whats wrong with 1 3 5