2023-11-03 06:32 PM
In the R3_2_GetPhaseCurrents(), the following line reads the ADC data register.
hReg1 = *pHandle->pParams_str->ADCDataReg1[bSector] * 2;
The value of the hReg1 will be used to compute the phase current later.
Why is the value of the ADC data register multiplied by 2?
Thanks in advance.
Solved! Go to Solution.
2023-11-06 07:37 AM
Hello @david11 ,
I guess you are using a STM32F4 MCU.
From the release manual (RM0368 Rev 5) , page 221, you can read this :
The converted data value from the injected group of channels is decreased by the userdefined offset written in the ADC_JOFRx registers so the result can be a negative value.
The SEXT bit represents the extended sign value.
For channels in a regular group, no offset is subtracted so only twelve bits are significant
With the following table :
As the FW consider the data left aligned, we must multiply the read value by 2 to align D11 with bit 15.
Hope it helps.
Regards
Cedric
2023-11-04 12:35 AM
I think that No one known what you talk about?
2023-11-06 07:37 AM
Hello @david11 ,
I guess you are using a STM32F4 MCU.
From the release manual (RM0368 Rev 5) , page 221, you can read this :
The converted data value from the injected group of channels is decreased by the userdefined offset written in the ADC_JOFRx registers so the result can be a negative value.
The SEXT bit represents the extended sign value.
For channels in a regular group, no offset is subtracted so only twelve bits are significant
With the following table :
As the FW consider the data left aligned, we must multiply the read value by 2 to align D11 with bit 15.
Hope it helps.
Regards
Cedric
2023-11-18 04:33 AM
I’ve figured it out a few days after I posted the question. I haven’t checked this forum for a while. Thanks a lot for your useful reply. It helps me make sure that my way of thinking is correct.