Skip to main content
Visitor II
October 11, 2021
Solved

Unable to initialize X-CUBE-MEMS1 libraries

  • October 11, 2021
  • 5 replies
  • 1796 views

I'm using a NUCLEO-L476RG with a STEVAL-MKI197V1, connected in SPI mode without any expansion board. My setup works: I successfully used the LSM6DSOX low-level driver to read sensor data.

But my attempts to use the high level libraries, such as MotionAC and MotionGC, have failed:

  • MotionAC_Initialize() and MotionGC_Initialize() always hang with a hard fault interrupt, and
  • MotionAC_GetLibVersion() and MotionGC_GetLibVersion() always return zero.

I think I've followed the setup instructions, including adding the CRC module, but obviously there's something I'm doing wrong. Any idea?

    This topic has been closed for replies.
    Best answer by paul19

    Everything is working fine now.

    For those landing here, here are the mistakes I made:

    1. I forgot to add the CRC component, hence the initial MotionGC_Initialize() hard fault interrupt.
    2. In order to debug this first issue, I used the MotionGC_GetLibVersion() function, but got mislead by the wrong diagram in UM2181 chapter 2.2.3. Remember to call MotionGC_GetLibVersion() *after* MotionGC_Initialize() or it will return zero.
    3. At this stage I got another hard fault interrupt, due to the fact that I forgot to enable USART DMA.

    @Miroslav BATEK​ , thanks a lot for your time on this. The fact that you could generate and run my own project file on your side freed my mind and unlocked everything. You might want to report the wrong "API flow chart" diagrams in MotionAC and MotionGC docs (and maybe in other libs as well).

    5 replies

    ST Employee
    October 11, 2021

    Would you please share your project so we can check it?

    paul19Author
    Visitor II
    October 11, 2021

    Sure @Miroslav BATEK​, here it is.

    ST Employee
    October 11, 2021

    Unfortunately I don't the sensor at hand but If I debug the generated project from your .ioc file on NUCLEO-L476RG board I able to pass the MotionGC_Initialize() function and the GetLibVersion() function returns correctly the library version.

    The only change I did was that I uncheck "Generate Under Root" but I don't think this the root cause.

    Would you please try it again and maybe increase the stack size.

    paul19Author
    Visitor II
    October 11, 2021

    @Miroslav BATEK​ , thanks a lot for looking into this.

    I doubled the stack size with no success.

    I noticed the MotionGC_GetLibVersion() function fails at its very beginning, after a single test. See here:

    0693W00000FC5UUQA1.pngIf you have access to the library source code, this might give a clue.

    paul19Author
    Visitor II
    October 11, 2021

    @Miroslav BATEK, I found my error regarding MotionGC_GetLibVersion(). I was calling it *before* the lib initialization, and it seems it's wrong, despite what's described in UM2181 chapter 2.2.3 diagram. So now MotionGC_GetLibVersion() works.

    paul19AuthorAnswer
    Visitor II
    October 11, 2021

    Everything is working fine now.

    For those landing here, here are the mistakes I made:

    1. I forgot to add the CRC component, hence the initial MotionGC_Initialize() hard fault interrupt.
    2. In order to debug this first issue, I used the MotionGC_GetLibVersion() function, but got mislead by the wrong diagram in UM2181 chapter 2.2.3. Remember to call MotionGC_GetLibVersion() *after* MotionGC_Initialize() or it will return zero.
    3. At this stage I got another hard fault interrupt, due to the fact that I forgot to enable USART DMA.

    @Miroslav BATEK​ , thanks a lot for your time on this. The fact that you could generate and run my own project file on your side freed my mind and unlocked everything. You might want to report the wrong "API flow chart" diagrams in MotionAC and MotionGC docs (and maybe in other libs as well).