cancel
Showing results for 
Search instead for 
Did you mean: 

SensorTile Drivers and Implementation

dylan
Associate III
Posted on March 20, 2018 at 11:21

Hello All,

I am having a a bit of an issue working with my SensorTile kit. I am able to get the demo apps working and so on, but I now want to start on my own project.

For the moment I have just tried to set the MCU up using CubeMX and I am trying to use the

https://github.com/STMicroelectronics/STMems_Standard_C_drivers/tree/master/lsm6dsm_STdC

 and I am only concentrating on the LSM6DSM. From what I understand all one has to do is write a function for SPI TX and RX and the rest should be taken care of by the driver. I have tried to emulate what the provided example does, but when I try to test communication by reading the WHO_AM_I register, I get no response. Attached is my main.c file and a screen shot of how I set SPI2 up in half duplex master mode. I have also attached the SPI.c that is generated by CubeMX.

If anyone can see anything I am doing incorrectly, please don't hesitate to point it out. Or Is it perhaps worth moving to the drivers in the x-cube-mems1 drivers.

Thanks,

Dylan

5 REPLIES 5
maurizio23
Associate II
Posted on March 28, 2018 at 17:14

Hi,

1) Are you sure that polarity of SPI is what MEMS want?

2) ou wrote: ' From what I understand all one has to do is write a function for SPI TX and RX and the rest should be taken care of by the driver'

Answer: NO! SPI library Write and Read must be combined to replicate the protocol SPI that datasheet explain. Tipically you combine a Write with Read  sequence into your function. A logic analyzer or scope can help you more to understand.

Maurizio

dylan
Associate III
Posted on March 28, 2018 at 17:28

Hi Maurizio,

Thanks for the response.

1) Yes, I have made sure of that. I have applied the same settings found in the application examples provided for the SensorTile.

2) Yes, I do realize that to read from an SPI device one has to send a request and then read the requested data and to send data to a device is also achieved by a request to send the data followed by the data and that these go into combined functions to adhere to the protocol. If you look at my functions in the attached code you will see that. I cannot use a logic analyzer as the SensorTile is traced on the board and there are no test points to probe - I would have diagnosed the issue this way if it were possible (Unless I am missing something?).

Thank you for the help. Any other suggestions would be great. 

Dylan

Posted on March 29, 2018 at 11:19

Hi,

at this point I suggest to move on x-cube-mems1 drivers. I'm starting to use the same drivers on my hardware hoping they works well.

It is very hard to have a support on MEMs from communities, have a commont task can help is we share problems and solution.

Good luck

Maurizio

Posted on April 18, 2018 at 18:38

Hi Dylan,

As suggested by Maurizio, you can have a look at one of the available SensorTile projects to see how the SPI 3-wires transactions are managed.

http://www.st.com/en/embedded-software/x-cube-mems1.html

 contains a simple example code for SensorTile that may be of interest.

I suggest you to look into 'sensortile.c' file, in particular at SPI_Read(...) function which handles correctly the SPI clock generation during the reading phase (the tricky part with SPI 3-wires).

Davide

Min-Kyoung Kim
Associate III

Hi Dylan,

I have same problem as you had.

Did you get the answer?