2020-11-05 09:59 PM
my mcu is STM32F730R8Tx
sensor: LSM9DS1
use CubeMx gen code, with Makefile(under linux env)
I use lsm9ds1_reg.c as sensor driver fetch raw data, and it worked fine.
then, do the following as MotionFX lib documents:
I can run the code, and i can get ther version code by MotionFX_GetLibVersion(): ST MotionFX v2.4.1
But, if i enable MotionFX_propagate() in the following routie, MCU will enter Hard Falut ISR...
if (is_imu_xl_gy_drdy())
{
MFX_input_t raw;
MFX_output_t out;
imu_getdata(&raw);
// curr_tick = HAL_GetTick();
// deltatime = (curr_tick - last_tick)/1000.0;
// last_tick = curr_tick;
deltatime = 0.01;
if (0)
{
len = snprintf(buf, 256, "%4.2f %4.2f %4.2f | %4.2f %4.2f %4.2f | %4.1f %4.1f %4.1f\n", raw.acc[0], raw.acc[1], raw.acc[2], raw.gyro[0], raw.gyro[1], raw.gyro[2], raw.mag[0], raw.mag[1], raw.mag[2]);
CDC_Transmit_FS(buf, len);
}
MotionFX_propagate(&out, &raw, &deltatime);
}
I have enable CRC in cubemx.
in Makefile, i did some change:
in STM32F730R8Tx_FLASH.ld
=============
But why HardFalut once calling MotionFX_propagate ?
Thank thee very much!!
2020-11-18 12:36 AM
Hi Eleon
Thank you!
I just try other lib: MotionEC.
Almost same problem, compile ok, MotionEC_Initialize ok, get MotionEC_GetLibVersion get expected return value.
But once call MotionEC_Run, mcu enter HardFault routine....
====
2020-11-18 12:41 AM
The units used for magnetometer data are uT/50.
Please check the user manual for MotionFX library.
So you need to use magentometer valeus in uT/50 units for all functions.
Also timestamp for MotionFX_MagCal_run funtion is not delta time but growing timestamp.
You can also check DatalogFusion application in X-CUBE-MEMS1 package which can be your reference how to use MotionFX library,
2020-11-18 12:43 AM
so, error data input can cause mcu enter HardFault routine?
2020-11-20 07:47 AM
In our test setup is doesn't cause HardFault, but I'm trying to recommend you changes to eliminate as much issues as possible.