Skip to main content
Visitor II
January 9, 2018
Solved

Can X-CUBE-MEMS1 libraries be used in B-L475E-IOT01A board?

  • January 9, 2018
  • 3 replies
  • 2029 views
Posted on January 09, 2018 at 15:53

I have a 

http://www.st.com/en/evaluation-tools/b-l475e-iot01a.html

, which I am using now to learn about how ST MEMS sensors work and if I can use them in my future PCB designs.

I have found recently that ST provides a library to mix 9-axis sensor data to calculate the orientation of any device. This libraries are in the 

http://www.st.com/en/embedded-software/x-cube-mems1.html

.

In my case, I want to use the 'MotionFX' library, mixing the data from Magnetometer+Gyroscope+Accelerometer which there are in this board.

My problem is that the function 'MotionFX_initialize()' gets stuck and never leave. Due to the fact that ST doesn't give us the source code of the library, I can't understand why this function doesn't work, because according to the documentation, there is no requirements or preconditions to use this function.

I have checked the assembly code (using TRUESTUDIO IDE) and this is the result:

MotionFX_initialize:

0800de00: ldr r1, [pc, &sharp880] ; (0x800e174 <MotionFX_initialize+884>)

0800de02: ldr r2, [pc, &sharp884] ; (0x800e178 <MotionFX_initialize+888>)

0800de04: stmdb sp!, {r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}

0800de08: ldr r3, [r1, &sharp0]

0800de0a: movs r0, &sharp1

0800de0c: bic.w r3, r3, &sharp1

0800de10: str r3, [r1, &sharp0]

0800de12: mov r3, r2

0800de14: str r0, [r2, &sharp0]

0800de16: ldr r5, [r3, &sharp0]

0800de18: cmp r5, &sharp0

0800de1a: bne.n 0x800de16 <MotionFX_initialize+22>

0800de1c: ldr r3, [pc, &sharp860] ; (0x800e17c <MotionFX_initialize+892>)

0800de1e: ldr r2, [pc, &sharp864] ; (0x800e180 <MotionFX_initialize+896>)

0800de20: str r2, [r3, &sharp0]

0800de22: ldr r2, [r3, &sharp0]

0800de24: ldr r3, [pc, &sharp860] ; (0x800e184 <MotionFX_initialize+900>)

0800de26: cmp r2, r3

0800de28: beq.n 0x800de2c <MotionFX_initialize+44>

0800de2a: b.n 0x800de2a <MotionFX_initialize+42>

The last assembly code line (

0800de2a

) is where the code gets stuck. As 

MotionFX_initialize function doesn't have any parameter, I guess all this assembly code is equal in every microcontroller or evaluation board.

In my TRUESTUDIO project, I use 'libMotionFX200_CM4F_GCC_ot.a' because 

http://www.st.com/en/evaluation-tools/b-l475e-iot01a.html

 board have a ARM-M4 microcontroller. I have configured correctly the project in order to link the library with the compiler. Even the whole project can compile without any error.

So, I wonder if there are limitations to use this library or if I have found out a bug. Can somebody who have used this library give me some help o tell me if you could use it without problems?

List of ideas I have tried so far:

  • In another post, I read this: 

    https://community.st.com/0D50X00009XkdlxSAB

    . But my CRC module has always been active and the library doesn't work.
  • Disabling optimizations.

  • Enabling optimizations to -O3 (because 'DataLogFusion' example do it).

  • Comparing the IDE configuration with the example, to check if the library linking is correct.♯

#motionfx #b-l475e-iot01a #initialize #x-cube-mems1
    This topic has been closed for replies.
    Best answer by Miroslav BATEK
    Posted on January 10, 2018 at 11:12

    OK, now I see the problem.

    Please use following settings or move the MX_CRC_Init() function after the 

    MotionFX_initialize();

    hcrc.Init.DefaultPolynomialUse = DEFAULT_POLYNOMIAL_ENABLE;

    hcrc.Init.DefaultInitValueUse = DEFAULT_INIT_VALUE_ENABLE;

    3 replies

    ST Employee
    January 9, 2018
    Posted on January 09, 2018 at 16:03

    If the code stuck in Initialize() function it is most probably because clock for CRC peripheral is not enabled.

    The CRC module in STM32 microcontroller (in RCC peripheral clock enable register) has to be enabled before using the library.

    This information will be soon added to the User Manual.

    Visitor II
    January 9, 2018
    Posted on January 09, 2018 at 16:25

    I am sorry. But CRC is not the solution in this situation.

    I have debugged my code and I set a breakpoint on '

    HAL_CRC_MspInit' (generated by STM32CUBEMX). So, I can confirm you that '__HAL_RCC_CRC_CLK_ENABLE' macro is being called. Moreover, I have checked that the macro is called before 'MotionFX_initialize' call.

    But the library is still stuck there.

    Are there more modules or peripherals I should active before calling MotionFX_initialize() ?

    ST Employee
    January 9, 2018
    Posted on January 09, 2018 at 16:33

    Do you have enough stack size?

    Visitor II
    January 10, 2018
    Posted on January 10, 2018 at 12:10

    Thank you!

    Finally, it worked! 

    By the way, I need to use the CRC peripheral with a different configuration (neither default polinomial nor initivalue). So, in order to use MotionFX, can't I use CRC anymore?

    Or maybe every time I want to use the CRC with custom configuration, do I have to do the next steps?

    1. HAL_CRC_Init() with my custom configuration.

    2. Use CRC to calculate whatever I need.

    3. HAL_CRC_Init() with the 'default' configuration.

    ST Employee
    January 10, 2018
    Posted on January 10, 2018 at 13:14

    The CRC peripheral is used only in MotionFX_initialize(); function so you can used it after initialization with you configuration.