2021-05-27 07:24 AM
Hello,
I am trying to implement a simple program on my STM32 NUCLEO F302R8, that reads data from a LSM6DSRX iNemo module (STEVAL MKI195V1) throught a NUCLEO-IKS01A2 extension board, and stores it in flash memory.
I am unable to find any kind of documentation, or code example for sensor reading using the lsd6dsrx library ('lsd6dsrx.h' file). For the time being I am using this structure but it lends me to an "Hard fault interrupt" that I don't know how to resolve.
If you could provide me an example of code using this captor it would be great.
For the record, I am currently initializing my captor this way :
/*USER CODE BEGIN 2*/
LSM6DSRX_Object_t gyro ;
if ( LSM6DSRX_Init(&gyro) == LSM6DSRX_OK){
LSM6DSRX_GYRO_Enable(&gyro);
}
Thank you in advance.
2021-05-28 05:21 AM
Hi @Loïc ARBEZ ,
I suggest you to check the C drivers on Github, in particular the lsm6dsrx_read_data_polling.c one.
A standard procedure for the initialization that enables the device to produce data can be the following one:
/* Disable I3C interface */
lsm6dsrx_i3c_disable_set(&dev_ctx, LSM6DSRX_I3C_DISABLE);
/* Enable Block Data Update */
lsm6dsrx_block_data_update_set(&dev_ctx, PROPERTY_ENABLE);
/* Set Output Data Rate */
lsm6dsrx_xl_data_rate_set(&dev_ctx, LSM6DSRX_XL_ODR_12Hz5);
lsm6dsrx_gy_data_rate_set(&dev_ctx, LSM6DSRX_GY_ODR_12Hz5);
/* Set full scale */
lsm6dsrx_xl_full_scale_set(&dev_ctx, LSM6DSRX_2g);
lsm6dsrx_gy_full_scale_set(&dev_ctx, LSM6DSRX_2000dps);
/* Configure filtering chain(No aux interface) Accelerometer - LPF1 + LPF2 path*/
lsm6dsrx_xl_hp_path_on_out_set(&dev_ctx, LSM6DSRX_LP_ODR_DIV_100);
lsm6dsrx_xl_filter_lp2_set(&dev_ctx, PROPERTY_ENABLE);
The drivers defining functions and registers are here lsm6dsrx_reg.h.
-Eleon
2021-06-02 05:32 AM
Hi @Eleon BORLINI , Thanks for your answer.
It served me well.
For the record, the problem i had was that I had not initialized the Ctx substructure contained in LSM6DSRX_Object_t because of that it was not able to read any registers.