I want to access the LSM6DSL via SPI. And I ´m always recieving 0x40, when I read the WHO AM I register. I expect 0x6A. I am sending 0x8F to read the WHO AM I register.. Any Idea why I am not recieving the right value?
question might be stupid, but did you set SPI datasize to 8bit?
I got the same problem during read WHO AM I regiester, and I am sure that 8bit SPI set.
Below is the time frames capture by LA. You can see that some jitters in SDO but the result of WHO AM I
Do anybody can help this issue?
I guess there is ringing on the clock edges and the sensor sends the data very quickly which you don't see on the logic analyzer. Actually you can see the short spike. Can you please decrease the clock speed and/or reduce the speed of GPIO pin which is used for SPI signals?
Hi Miroslav B,
Thank you for reply. But the clock was just about 500KHz and the spec announce they can accept 8MHz.
By the way, even MCU can detect the jitter, the result will not be 0x6A as spec announce.
Actually, I have reduce to 200KHz, but the result was the same.
In the picture above I see that the ckock frequency is ~2MHz.
What is the distance between MCU and the sensor?
Is the sensor somehow configured before you read the who_am_i. If yes can you please send the configuration.
I found the root cause.
If VCC input set as 1.8V, SPI_MISO would output correct.
If VCC input set over 2.2V, SIP_MISO would output as wrong data.
Below 2 picture with the same code to read register 0x0F (WHO AM I)
VCC 1.8V output 0x6A but VCC 2.2V output 0x40
I solved the problem by adding a 100 ohm resistor in series on the MISO line...
OK, good. I confirms my assumption that there was ringing on the edges.
Retrieving data ...