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.

 

0 REPLIES 0