AnsweredAssumed Answered

MotionFX hard fault

Question asked by Norman S on Feb 28, 2018
Latest reply on Feb 28, 2018 by Bogdan Golab



I'm trying to implement MotionFX in my application. So far I have a very basic setup which executes correctly.

  printu(ver, 1);
  iKnobs.output_type = MFX_ENGINE_OUTPUT_ENU;
  iKnobs.LMode = 1;
  iKnobs.modx = 1;


Then, in a thread, I pull data out of my sensors and push it to the motionfx:


  MFX_input_t data_in;
  MFX_output_t data_out;
  data_in.acc[0] = mptr->acc.AXIS_X * FROM_MG_TO_G;
  data_in.acc[1] = mptr->acc.AXIS_Y * FROM_MG_TO_G;
  data_in.acc[2] = mptr->acc.AXIS_Z * FROM_MG_TO_G;
  data_in.gyro[0] = mptr->gyro.AXIS_X * FROM_MDPS_TO_DPS;
  data_in.gyro[1] = mptr->gyro.AXIS_Y * FROM_MDPS_TO_DPS;
  data_in.gyro[2] = mptr->gyro.AXIS_Z * FROM_MDPS_TO_DPS;
  data_in.mag[0] = mptr->mag.AXIS_X * FROM_MGAUSS_TO_UT50;
  data_in.mag[1] = mptr->mag.AXIS_Y * FROM_MGAUSS_TO_UT50;
  data_in.mag[2] = mptr->mag.AXIS_Z * FROM_MGAUSS_TO_UT50;
  MotionFX_propagate(&data_out, &data_in, 0.01);
  MotionFX_update(&data_out, &data_in, 0.01, NULL);


For now, the 0.01 deltatime variable is not accurate, but will be corrected later.


The problem is that I can not call the _propagate and _update function. If I leave only _propagate, I can call that function ripediatelly and get some results. Same with _update. However, if I call them both with each iteration, I run into a hard fault every time.


I have increased stack size to 0x6000 in .ld file with the same results.


In my debugging, it seems that the two functions run fine outside of the thread context.