2025-02-26 12:24 PM
I'm struggling with programming the ISM330DHCX on a sony spresense. By following the documentation I write my register with these values:
CTRL1_XL: 0b01001000
CTRL2_G: 0b01001100
FIFO_CTRL1: 0b10010000
FIFO_CTRL2: 0b00000000
FIFO_CTRL3: 0b01000100
FIFO_CTRL4: 0b00000110
FIFO_CTRL3C: 0b01000100
The I read the FIFO (SPI) with this kind of code :
void ISMSensor::read_FIFO(uint8_t *buffer, uint8_t ism_watermark)
{
uint16_t transferSize = (ism_watermark * 7) + 1;
uint8_t tx_rx_buffer[transferSize];
tx_rx_buffer[0] = ISM330::ISM_REG::REG_FIFO_DATA_OUT_TAG | 0x80;
for (uint16_t i = 1; i < transferSize; i++) {
tx_rx_buffer[i] = 0x00;
}
bus->beginTransaction(spiSettings);
digitalWrite(csPin, LOW);
bus->transfer(tx_rx_buffer, transferSize);
digitalWrite(csPin, HIGH);
bus->endTransaction();
memcpy(buffer, &tx_rx_buffer[1], ism_watermark * 7);
}
Unfortunately, the values read are aberrant (~0 g on the Z axis) although :
1) The FIFO data tag is correct but value seems aberrant
0x09, 0x71, 0xFF, 0x2D, 0x00, 0x7F, 0x00, (accel)
0x11, 0x04, 0x80, 0xFC, 0x7F, 0xFC, 0x7F, (gyro)
0x0A, 0x71, 0xFF, 0x2D, 0x00, 0x7F, 0x00, (accel)
0x12, 0xFC, 0x7F, 0x46, 0x0D, 0xFC, 0x7F, (gyro)
2) when reading ISM OUT register, values are correct. (± 1g on z axis up or down)
I don't understand where my mistake or oversight came from.
Can anyone help me?