cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to initialize X-CUBE-MEMS1 libraries

paul19
Associate III

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?

1 ACCEPTED SOLUTION

Accepted Solutions
paul19
Associate III

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

View solution in original post

6 REPLIES 6
Miroslav BATEK
ST Employee

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

paul19
Associate III

Sure @Miroslav BATEK​, here it is.

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.

paul19
Associate III

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

paul19
Associate III

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

paul19
Associate III

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