cancel
Showing results for 
Search instead for 
Did you mean: 

Interfacing LIS3DH

Manoj Hiwarkar
Associate III
Posted on May 12, 2018 at 08:52

Dear sir,

I want to read X,Y,Z data from LIS3DH. I have gone through the datasheet of the same but still didn't understand what are the commands to access it. So it will be kind of you if you tell me the commands or algorithm to read the data.

Regards,

Manoj Hiwarkar

4 REPLIES 4
Posted on May 12, 2018 at 12:08

You interact with the part on the bus you're using to read the internal registers in the device, the data sheet should enumerate the register locations and content. How it is wired to your micro-controller will impact how you access it.

If you are unfamiliar with micro-controllers and interfacing there are likely books or courses on such things.

There are example drivers for various STM32 platforms in the HAL/CUBE releases:

STM32Cube_FW_F4_V1.18.0\Drivers\BSP\Components\lis3dsh\lis3dsh.c

STM32Cube_FW_F4_V1.18.0\Drivers\BSP\Components\l3gd20\l3gd20.c

I'd imagine a web search would yield many more examples

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 12, 2018 at 12:39

I am using nrf 52832. do we have any driver for this ?

Posted on May 12, 2018 at 13:10

Me personally, no.

Do you have it connected via SPI or I2C? Standard drivers for those interfaces on that platform should be able to access the registers within the device. The example code on the STM32 above is abstracted at the level above the SPI/I2C. This might be portable, or you might find code you like better for a Flight Controller or INS implementation, using the the LIS3DH

/**

  * @brief  Read LIS3DSH device ID.

  * @param  None

  * @retval The Device ID (two bytes).

  */

uint8_t LIS3DSH_ReadID(void)

{

  uint8_t tmp = 0;

  /* Configure the low level interface */

  ACCELERO_IO_Init();

  /* Read WHO_AM_I register */

  ACCELERO_IO_Read(&tmp, LIS3DSH_WHO_AM_I_ADDR, 1);

  /* Return the ID */

  return (uint16_t)tmp;

}
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 12, 2018 at 17:32

Yes we have connected it via i2c

On Sat 12 May, 2018, 4:41 PM Clive One, <st-microelectronics@jiveon.com>