Skip to main content
Associate
November 4, 2023
Solved

ADC injected group conversion

  • November 4, 2023
  • 2 replies
  • 1657 views

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.

    This topic has been closed for replies.
    Best answer by cedric H

    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 :

    cedricH_0-1699284841017.png

    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

    2 replies

    Tinnagit
    Senior II
    November 4, 2023

    I think that No one known what you talk about?

    cedric H
    cedric HBest answer
    Technical Moderator
    November 6, 2023

    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 :

    cedricH_0-1699284841017.png

    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

    david11Author
    Associate
    November 18, 2023

    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.