Unable to initialize X-CUBE-MEMS1 libraries
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-11 2:34 AM
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?
Solved! Go to Solution.
- Labels:
-
Developers Corner
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-11 6:25 AM
Everything is working fine now.
For those landing here, here are the mistakes I made:
- I forgot to add the CRC component, hence the initial MotionGC_Initialize() hard fault interrupt.
- 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.
- 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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-11 2:47 AM
Would you please share your project so we can check it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-11 2:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-11 5:07 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-11 5:37 AM
@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:
If you have access to the library source code, this might give a clue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-11 5:56 AM
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-11 6:25 AM
Everything is working fine now.
For those landing here, here are the mistakes I made:
- I forgot to add the CRC component, hence the initial MotionGC_Initialize() hard fault interrupt.
- 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.
- 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).
