2018-05-11 11:52 PM
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
2018-05-12 03:08 AM
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
2018-05-12 05:39 AM
I am using nrf 52832. do we have any driver for this ?
2018-05-12 06:10 AM
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;}2018-05-12 10:32 AM
Yes we have connected it via i2c
On Sat 12 May, 2018, 4:41 PM Clive One, <st-microelectronics@jiveon.com>