Hi, I am currently using the STEVAL-MKI208V1K sensor kit based on IIS3DWB. It is used with a 4-Bit Bidirectional Voltage-level Translator and Arduino Nano (ATMega328P) through SPI, where the Arduino is the Master and the sensor is the Slave.
I am facing problems in getting the acceleration values using the OUTX_L_A to OUTZ_H_A (0x28 to 0x2D) registers. However, I am able to read some registers such as the WHO_AM_I (0x0F) and PIN_CTRL (0x02) registers. When reading the values, I will change the bit 0 to 1 (in page 13 IIS3DWB Datasheet), and I have configured the SPI settings to MSB first. For example, if reading WHO_AM_I (0x0F) register, it will be changed to 0x8F. I am wondering why I am unable to change/set the register value for CTRL1_XL at 10100000 through doing a read register then a write.
I referred to these few websites: A example sketch for Arduino SPI communication | lbaigy's Tech-Blog , Problems reading a register value with SPI - Installation & Troubleshooting - Arduino Forum , NightShade Electronics - Home .
Any help would be appreciated, thank you.
The first version doesn't even try to read the mentioned registers. Additionally the beginTransaction()/endTransaction() isn't used correctly.
The second version doesn't set CS HIGH by default, so the first read might fail. Also it shifts the register address for no obvious reason. I would expect the readRegister()/writeRegister() functions to fail for all register numbers.