Skip to Content
Block descriptionsSensorsLIS3DSH

LIS3DSH Sensor Block Description

This block supports LIS3DSH sensor on STM microcontrollers. LIS3DSH is a 3-axis MEMS accelerometer that can be used to measure acceleration along three axes (X, Y, Z) and temperature. This block allows reading data from the sensor using either I2C or SPI interfaces, enabling integration with various STM32 microcontroller models.



LIS3DSH sensor block

Contents

Inputs

This block does not have any inputs.

Outputs

Output NameTypeDescription
Inituint8Initialization status of the LIS3DSH sensor. Returns
1 for successful initialization
0 (or an error code) if the setup failed.
New datauint8Data ready flag:
1 - new data is ready to read
0 - data is not ready to read / read error
AxdoubleMeasured acceleration along the X-axis, scaled according to the selected full-scale configuration.
AydoubleMeasured acceleration along the Y-axis, scaled according to the selected full-scale configuration.
AzdoubleMeasured acceleration along the Z-axis, scaled according to the selected full-scale configuration.
TempsingleConditional output
Temperature reading from the sensor’s internal temperature sensor.
Note: This output is exposed only when the Read parameter is configured to Akclereometer + Temperature.

Block parameters for I2C and SPI

Block parameters for I2C

ParameterDescription
SensorSwitch between available sensors
InterfaceSwitch between interfaces:
I2C - select I2C interface
SPI - select SPI interface
Module numberNumber of I2C/SPI module used in the model
AddressAddress of the slave motion sensor
ReadSpecifies what data is being read:
Akcelerometer - read accelerometer data
Akclereometer + Temperature - read accelerometer and temperature data
Frequency data outputLIS3 data output rate in Hz
Full-scale [gauss]Full-scale configuration
Output data typeSpecified type of reading data:
int16 - integer 16-bit
single - single-precision floating-point
double - double-precision floating-point
TimeoutTimeout duration
Number of testsSpecified maximum number of tries to initialize the sensor
Sample timePeriod of function refreshing

Parameter Sample time defines the execution period (refresh rate) of the block. Note that this is independent of the internal LIS3MDL sensor conversion time.

Special values: -1 (Inherited): The block inherits the sample time from its upstream input block. If no input block is connected, it automatically adopts the fastest sample time available within the entire model.



Block parameters for I2C

Block parameters for SPI

ParameterDescription
SensorSwitch between available sensors
InterfaceSwitch between interfaces:
I2C - select I2C interface
SPI - select SPI interface
Module numberNumber of I2C/SPI module used in the model
CS PinSpecified pin for the chip select line
CS PortSpecified port for the chip select line
ReadSpecifies what data is being read:
Akcelerometer - read accelerometer data
Akclereometer + Temperature - read accelerometer and temperature data
Frequency data outputLIS3 data output rate in Hz
Full-scale [gauss]Full-scale configuration
Output data typeSpecified type of reading data:
int16 - integer 16-bit
single - single-precision floating-point
double - double-precision floating-point
TimeoutTimeout duration
Number of testsSpecified maximum number of tries to initialize the sensor
Sample timePeriod of function refreshing


Block parameters for SPI

CubeMX Configuration for a Given MCU

Dependent on the interface

I2C interface

Nb.NamePathSettingDescriptionScreenshot
1I2C ModePinout & Configuration > Connectivity > I2C* > ModeI2CI2C Mode should be set to I2CI2C Mode setting
2I2C Clock SpeedPinout & Configuration > Connectivity > I2C* > Parameter Settings > Timing configuration > I2C Speed ModeFast ModeI2C Clock Speed can be set maximum as 400 kHz in Fast ModeI2C Clock Speed setting

I2C* - simbol * is a number of the I2C module used in the model, e.g. I2C1, I2C2, etc.

SPI interface

Nb.NamePathSettingDescriptionScreenshot
1SPI ModePinout & Configuration > Connectivity > SPI* > ModeFull-Duplex MasterSPI Mode should be set to Full-Duplex MasterSPI Mode setting
2SPI Baud RatePinout & Configuration > Connectivity > SPI* > Parameter Settings > ModeFull-Duplex MasterSPI Baud Rate can be set maximum as 10 MBits/s. This setting depends on the SPI clock and PrescalerSPI Baud Rate setting

I2C* - simbol * is a number of the SPI module used in the model, e.g. I2C1, I2C2, etc.

Last updated on