I have several successful designs with STM32 PMSM FOC LIBv4.0, but from time to time I noticed some irregularities, causing the motor to "click" while spinning (1kW PMSM). It sounds like someone is hitting it with a small hammer. This happened seldomly, and I never could reliably reproduce it in the past, in order to track it down.
Last week I had this situation again, and it happened frequently enough to allow finding the root cause. It turned out to be the library module dealing with the encoder feedback, in combination with a noisy electrical encoder signal. It turned out that the (v.4.0) library module cannot handle a noisy encoder feedback that causes temporary direction reversals. When this happens simultaneously with a timer overflow or underflow, then it calculates wrong speed information, which is causing the "clicks".
I have revised the entire encoder module (ENC_F4xx_SpeednPosFdbkClass.c, ENC_F4xx_SpeednPosFdbkPrivate.h) and implemented a more robust algorithm, which is also more efficient and does not need interrupts. I would like to share it with the community, but as the library source code is NDA protected, I am asking the ST team how to proceed here.