cancel
Showing results for 
Search instead for 
Did you mean: 

MotionFX hard fault

Norman S
Associate II
Posted on February 28, 2018 at 07:26

Hello,

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

 MotionFX_initialize();
 MotionFX_GetLibVersion(ver);
 printu(ver, 1);
 MotionFX_getKnobs(&iKnobs);
 iKnobs.output_type = MFX_ENGINE_OUTPUT_ENU;
 iKnobs.LMode = 1;
 iKnobs.modx = 1;
 MotionFX_setKnobs(&iKnobs);
 MotionFX_enable_6X(MFX_ENGINE_DISABLE);
 MotionFX_enable_9X(MFX_ENGINE_ENABLE);�?�?�?�?�?�?�?�?�?�?

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 becorrected 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.

19 REPLIES 19

I think you configured the stack size to small.

GHerr.18
Associate II

I was tried to increase the stack but it does the same.

I was tried to increase the stack but it does the same.

What stack size did you try?

_Min_Stack_Size = 0x1000; /* required amount of stack */

I would try to increase it even more e.g. 0x2000.

I tried with 0x2000 and 0x3000 and it do the same...

But, I think, It's not the problem, The code is the same for the RB and, with than microcontroller works fine!

PD. Sorry for the delay

It is really strange, there must be something wrong it your project. There is not reason why it should not work on the MCU with more memory.

yes! I think so.

I made the projects with STM32CubeMX and I didn't change the configuration.

I can't understand...

MMa.1893
Associate III

i meet the similar problem..

I have enable CRC and enlarge _Min_Stack_Size = 0x8000, but no help...