Skip to main content
Associate
Mar 3, 2025 10:17 AM UTC
Solved

STM32WB15CC (B-WB1M-WPAN) cannot initilize MotionFx

I've been using B-WB1M-WPAN board with a modified example of motion service from BLE_HR_p2p_Sensor. but with IMU readings with a steval-mki217v1 shield connected with SPI.

I already have the CRC checked from CubeMX generation.

 

So far I have been able to read IMU data (polling) and send it through a BLE notifiacation service. but when I try to setup a MotionFx server it mulfunctions.

void ssfusn_setup(void)
{
 /* Check if statically allocated memory size is sufficient to store MotionFX algorithm state and resize if necessary */
 if (STATE_SIZE < MotionFX_GetStateSize())
 {
 // Error_Handler();
 while (1)
 {
 /* code */
 }

 } /* Sensor Fusion API initialization function */

 MotionFX_GetLibVersion(lib_version);
 MotionFX_initialize((MFXState_t *)mfxstate);
 MotionFX_getKnobs(mfxstate, &iKnobs);
 iKnobs.acc_orientation[0] = 's';
 iKnobs.acc_orientation[1] = 'e';
 iKnobs.acc_orientation[2] = 'u';
 iKnobs.gyro_orientation[0] = 's';
 iKnobs.gyro_orientation[1] = 'e';
 iKnobs.gyro_orientation[2] = 'u';
 iKnobs.mag_orientation[0] = 'n';
 iKnobs.mag_orientation[1] = 'e';
 iKnobs.mag_orientation[2] = 'u';

 iKnobs.gbias_acc_th_sc = GBIAS_ACC_TH_SC;
 iKnobs.gbias_gyro_th_sc = GBIAS_GYRO_TH_SC;
 iKnobs.gbias_mag_th_sc = GBIAS_MAG_TH_SC;

 iKnobs.output_type = MFX_ENGINE_OUTPUT_ENU;
 iKnobs.LMode = 1;
 iKnobs.modx = DECIMATION;
 // ____________________________________________________________________________
 MotionFX_setKnobs(mfxstate, &iKnobs);
 MotionFX_enable_6X(mfxstate, MFX_ENGINE_DISABLE);
 MotionFX_enable_9X(mfxstate, MFX_ENGINE_ENABLE); /* Enable 9-axis sensor fusion */
}

 

here are some combinations I've tried. with this line of code above.

1. when initialize after MX_APPE_Init(); in main.c the device will enter a hardfault error in couple of loops. same goes when put on app context init.

2. when initialize before MX_APPE_Init(); it does not process the registered UTIL_SEQ_RegTask. But the device works fine.

When I remove the BLE stack and left with the IMU reading with SPI.

3. when initialize before main loop, The IMU stops returning data.

This topic has been closed for replies.
ZefieBest answer
Associate
Mar 21, 2025 8:02 AM UTC

Turns out I didn't have enough stack/heap. I bumped those up to 0x1000, it now works.

2 replies

ZefieAuthor
Associate
Mar 11, 2025 6:55 AM UTC

Any update on this ? Am I missing any information?

ZefieAuthorBest answer
Associate
Mar 21, 2025 8:02 AM UTC

Turns out I didn't have enough stack/heap. I bumped those up to 0x1000, it now works.