cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong code in R3_2_CurrentReadingCalibration?

llm
Associate III

used sdk : 5.4.7

mcu : stm32f446re

dual motor

In function R3_2_CurrentReadingCalibration has below code:

 pHandle->PhaseAOffset >>= 3;

 pHandle->PhaseBOffset >>= 3;

 pHandle->PhaseCOffset >>= 3;

But NB_CONVERSIONS is defined 16u, So is it true the right code should be

 pHandle->PhaseAOffset >>= 4;

 pHandle->PhaseBOffset >>= 4;

 pHandle->PhaseCOffset >>= 4;

I checked the example code used stm32g431 as below:

 pHandle->PhaseAOffset /= NB_CONVERSIONS;

 pHandle->PhaseBOffset /= NB_CONVERSIONS;

 pHandle->PhaseCOffset /= NB_CONVERSIONS;

1 REPLY 1
GMA
ST Employee

Dear llm,

Firstly, we would like to sincerely apologize for the delay in replying to your post.
If your point is still pertinent, the difference comes from ADC 12bit left data alignment for STM32F4/F7 series, please check RM0390  for more detail.
As injected conversions results are left shifted by one and PhasexOffset computation done without this left shift, the result is (PhasexOffset <<1)>>4, then >>3 is used.

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