I'm writing to ask if someone has ever encountered a quite weird behaviour of LIS3DSH.

to properly use such sensor, a number of registers must be configured via the spi bus. I implemented a routine to do so, which writes the registers in sequence and reads them back to check the operation result. The function gets stuck on the very first register it tries to configure, which determines the active channels and the data rate: CTRL_REG_4. This register, as others, is declared R/W; but, whatever I send into it, I read a 'zero' back (which according to the documentation is not even the default value anyway).

After spending long looking for a bug in my spi R/W functions, I skipped that register and noticed that others work just as expected, so I tend to believe there's something wrong with that specific memory location.

Can anybody read from it?

  • \$\begingroup\$ Is it possible you're working with a different part with slightly different registers? \$\endgroup\$ – duskwuff May 11 '18 at 21:43
  • \$\begingroup\$ So it is working fine otherwise? Does this behavior occur on the first register read / write, regardless of what the register is? Could be an initialization issue / incorrect start condition on the bus. \$\endgroup\$ – Krunal Desai May 11 '18 at 21:50
  • \$\begingroup\$ 1. No, the part is a LIS3DSH 2. No, it simply was bad luck if that register was the first I tried to setup, all others work if I just skip that one. \$\endgroup\$ – GioP May 12 '18 at 6:34
  • \$\begingroup\$ All ST MEMS parts have some home-brewn "SPI" which isn't industry standard. Read the datasheet very carefully, likely you have to add manual delays etc. Iirc you might also need to send some dummy information after the command: that is, it might not work in duplex (like a shift register) but rather in semi-duplex. If there was an actual SPI ISO standard it would save engineers so much of this head ache. \$\endgroup\$ – Lundin May 14 '18 at 14:58
  • \$\begingroup\$ Last summer I eventually made some further analysis on this topic I forgot to post here. community.st.com/s/question/0D50X00009kHRHISA4/… \$\endgroup\$ – GioP Jan 14 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.