cancel
Showing results for 
Search instead for 
Did you mean: 

[Bug report] MCM_Modulus does not work for negative alpha values when using CORDIC

Sune Jensen
Associate II

[VERSION]: 6.3.1
[TOOL]: Firmware


[DETAILS]:
The implementation of MCM_Modulus defined in mc_math.h calls the CORDIC peripheral like this:

 

LL_CORDIC_WriteData(CORDIC, (((uint32_t)beta << 16U) | (uint32_t)alpha));

 

This works fine as long as alpha is positive. However, when converting a negative alpha from int16_t to uint32_t the upper 16 bits will all be '1', hence beta is overwritten.

 

[PROPOSED SOLUTION]:
Mask the upper bits of alpha before combining with beta.

LL_CORDIC_WriteData(CORDIC, (((uint32_t)beta << 16U) | ((uint32_t)alpha & 0xFFFF)));

 

Note: Images are attached that show calculated phase current using the wrong and the correct conversions respectively.

 

1 ACCEPTED SOLUTION

Accepted Solutions
GMA
ST Employee

Hello @Sune Jensen,

This issue has been fixed in our new MCSDK 6.3.2 release,
so feel free to download it here and try if it solved correctly your issue reported in this post.

If you agree with the answer, please accept it by clicking on 'Accept as solution'.
Best regards.
GMA

View solution in original post

2 REPLIES 2
GMA
ST Employee

Hello @Sune Jensen,

Thank you for your problem report. A ticket has been entered on our side and notification will be done once corrected in further delivery.

If you agree with the answer, please accept it by clicking on 'Accept as solution'.
Best regards.
GMA
GMA
ST Employee

Hello @Sune Jensen,

This issue has been fixed in our new MCSDK 6.3.2 release,
so feel free to download it here and try if it solved correctly your issue reported in this post.

If you agree with the answer, please accept it by clicking on 'Accept as solution'.
Best regards.
GMA